<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0080)http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170708&showall=true -->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Practice Test III_files/styles.php">
<link rel="stylesheet" type="text/css" href="./OCPJP 6 - Exam Simulator  Practice Test III_files/styles(1).php">

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie7.css" />
<![endif]-->
<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="http://www.whizlabs.com/examprep/theme/standard/styles_ie6.css" />
<![endif]-->


    <meta name="keywords" content="moodle, OCPJP 6 - Exam Simulator: Practice Test III ">
    <title>OCPJP 6 - Exam Simulator: Practice Test III</title>
    <link rel="shortcut icon" href="http://www.whizlabs.com/examprep/theme/ability-to-learn/favicon.ico">
    <!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(http://www.whizlabs.com/examprep/lib/csshover.htc);} /*]]>*/</style>-->

<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/javascript-static.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/javascript-mod.php"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/overlib.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/overlib_cssstyle.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cookies.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/ufo.js"></script>
<script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/dropdown.js"></script>  

<script type="text/javascript" defer="defer">
//<![CDATA[
setTimeout('fix_column_widths()', 20);
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
function openpopup(url,name,options,fullscreen) {
  fullurl = "http://www.whizlabs.com/examprep" + url;
  windowobj = window.open(fullurl,name,options);
  if (fullscreen) {
     windowobj.moveTo(0,0);
     windowobj.resizeTo(screen.availWidth,screen.availHeight);
  }
  windowobj.focus();
  return false;
}

function uncheckall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=0);
  }
}

function checkall() {
  void(d=document);
  void(el=d.getElementsByTagName('INPUT'));
  for(i=0;i<el.length;i++) {
    void(el[i].checked=1);
  }
}

function inserttext(text) {
  text = ' ' + text + ' ';
  if ( opener.document.forms['theform'].message.createTextRange && opener.document.forms['theform'].message.caretPos) {
    var caretPos = opener.document.forms['theform'].message.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  } else {
    opener.document.forms['theform'].message.value  += text;
  }
  opener.document.forms['theform'].message.focus();
}

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
//]]>
</script>
    
		<style type="text/css">
	<!--
	#main {
		min-height: 500px;
		width: 988px;
		margin: auto;
		background:#fff;
	}
	#header {
		height: 90px;
		width: 988px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/header.gif);
	}
	#navi {
		float: left;
		height: 22px;
		width: 828px;
		padding: 10px 0pt 0pt 20px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_02.gif);
	}
	#navi2 {
		height: 32px;
		width: 140px;
		float: left;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/part3left.gif);
		text-align: left;
	}
	#left {
		float: left;
		min-height: 675px;
		width: 263px;
	}
	
	#leftinsertdiv {
		float: left;
		height: 58px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-left-down_04.gif);
	}
	
	#left3 {
		float: left;
		height: 617px;
		width: 21px;
		/*background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_05.gif);*/
	}
	
	#left4 {
		height: 58px;
		width: 242px;
		float: right;
	}
	#left5 {
		float: right;
		height: 62px;
		width: 242px;
	}
	#left6 {
		float: right;
		min-height: 160px;
		width: 242px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_06-19.gif);
	}
	#right {
		float: left;
		min-height: 601px;
		width: 725px;
		background:#fff;
	}
	#leftfooter {
		float: left;
		height: 159px;
		width: 263px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/footerdiv.gif);
		background-repeat:no-repeat;
	}
	#rightfooter {
		float: left;
		height: 50px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_10-53.gif);
		background-position:left bottom;
		background-repeat:no-repeat;
		padding-top:90px;
		background-color:#fff;
	}
	#rightfooter2 {
		float: left;
		height: 19px;
		width: 725px;
		background-image: url(http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_54.gif);
	}
	-->
	</style>
	
<link href="./OCPJP 6 - Exam Simulator  Practice Test III_files/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/document_iterator.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/find_proxy.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/get_html_text.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/global_constants.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/name_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/number_injection_builder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/string_finder.js"></script><script src="chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/change_sink.js"></script><meta name="document_iterator.js"><meta name="find_proxy.js"><meta name="get_html_text.js"><meta name="global_constants.js"><meta name="name_injection_builder.js"><meta name="number_injection_builder.js"><meta name="string_finder.js"><meta name="change_sink.js"><style charset="utf-8" type="text/css" id="">SPAN.skype_pnh_container SPAN.skype_pnh_mark{  display:none !important;}@media screen{SPAN.skype_pnh_print_container_1323210120{  display:none !important;}SPAN.skype_pnh_container, SPAN.skype_pnh_container *{background-attachment: scroll !important;background-color: transparent !important;background-image: none !important;background-position: 0px 0px ! important;background-repeat: no-repeat !important;border: 0px none !important;border-color: #000000 !important;border-style: none !important;border-width: 0 !important;border-left: 0 none #000000 !important;border-top: 0 none #000000 !important;border-right: 0 none #000000 !important;border-bottom: 0 none #000000 !important;border-left-color: #000000 !important;border-left-style: none !important;border-left-width: 0 !important;border-top-color: #000000 !important;border-top-style: none !important;border-top-width: 0 !important;border-right-color: #000000 !important;border-right-style: none !important;border-right-width: 0 !important;border-bottom-color: #000000 !important;border-bottom-style: none !important;border-bottom-width: 0 !important;border-collapse: separate !important;bottom: auto !important;clear: none !important;clip: auto !important;cursor: pointer !important;direction: ltr !important;display: inline !important;float: none !important;font-style: normal !important;left: auto !important;letter-spacing: 0 !important;list-style-image: none !important;list-style-position: outside !important;list-style-type: disc !important;overflow: hidden !important;overflow-x: hidden !important;overflow-y: hidden !important;padding: 0px 0px 0px 0px !important;padding-left: 0px !important;padding-top: 0px !important;padding-right: 0px !important;padding-bottom: 0px !important;page-break-after: auto !important;page-break-before: auto !important;page-break-inside: auto !important;position: static !important;right: auto !important;table-layout: auto !important;text-align: left !important;text-decoration: none !important;text-indent: 0px !important;text-transform: none !important;top: auto !important;voice-family: inherit !important;white-space: nowrap !important;word-spacing: normal !important;z-index: 0 !important;  color: #49535A !important;  font-family: Tahoma, Arial, Helvetica, sans-serif !important;  font-size: 11px !important;  font-weight: bold !important;  height: 14px !important;  line-height: 14px !important;  margin-left: 0px !important;  margin-top: 0px !important;  margin-right: 0px !important;  margin-bottom: 0px !important;  vertical-align: baseline !important;  width: auto !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax SPAN.skype_pnh_right_span, SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax SPAN.skype_pnh_right_span{  background-position: -92px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_textarea_span{  background-position: -90px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free SPAN.skype_pnh_text_span{  visibility: hidden !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_dropart_flag_span{  background-position: 0px 1px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_textarea_span{  background-position: -160px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free SPAN.skype_pnh_text_span{  background-position: -160px 0px !important;  color: #FFFFFF !important;}SPAN.skype_pnh_container SPAN.skype_pnh_left_span{  background-position: 0px 0px !important;  width: 6px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_span{  background-position: -11px 0px !important;  width: 27px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_wo_arrow_span{  background-position: -130px 0px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-position: 1px 1px !important;  width: 18px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_textarea_span{  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_text_span{  padding-left: 5px !important;  background-position: -125px 0px !important;}SPAN.skype_pnh_container SPAN.skype_pnh_right_span{  background-position: -62px 0px !important;  width: 15px !important;}}@media print{SPAN.skype_pnh_print_container_1323210120{}SPAN.skype_pnh_container{    display:none !important;}}@media screen{SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_common *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_inactive_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_fax *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_common_active_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_inactive_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_highlighting_active_free *{  background-image:url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/numbers_free_icon_set.gif') !important;}SPAN.skype_pnh_container SPAN.skype_pnh_dropart_flag_span{  background-image: url('chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl/flags.gif') !important;}}</style></head>
<!-- WANT URL-->

<body class="mod-quiz course-11 dir-ltr lang-en_utf8" id="mod-quiz-review" onload="MM_preloadImages(&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-up_07.gif&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/psd-over_05.gif&#39;);">


<div id="main">
  <div id="header"><br>
    <p class="headertxt">Call Us at <span class="skype_pnh_print_container_1323210120">+1-818-575-6625</span><span class="skype_pnh_container" dir="ltr" tabindex="-1"><span class="skype_pnh_mark"> begin_of_the_skype_highlighting</span>&nbsp;<span class="skype_pnh_highlighting_inactive_common" dir="ltr" skypeaction="skype_dropdown" title="Call this phone number in United States of America with Skype: +18185756625"><span class="skype_pnh_left_span" skypeaction="skype_dropdown" title="Skype actions">&nbsp;&nbsp;</span><span class="skype_pnh_dropart_span" skypeaction="skype_dropdown" title="Skype actions"><span class="skype_pnh_dropart_flag_span" skypeaction="skype_dropdown" style="background-position: -5849px 1px !important; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;</span><span class="skype_pnh_textarea_span"><span class="skype_pnh_text_span">+1-818-575-6625</span></span><span class="skype_pnh_right_span">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>&nbsp;<span class="skype_pnh_mark">end_of_the_skype_highlighting</span></span> | <a href="http://www.whizlabs.com/examprep/login/logout.php?sesskey=PRYpcjl16t">Sign Out</a> | <a href="http://www.whizlabs.com/index.php?option=com_whizmart&view=cart">My Cart</a> | <a href="http://www.whizlabs.com/examprep/user/view.php">Change Password</a></p>
    <p class="txtheader">Welcome <a href="http://www.whizlabs.com/examprep">Flavio&nbsp;Vit !</a></p>
  </div>


  <div id="navi" class="breadcrumb"><h2 class="accesshide ">You are here</h2> <ul>
<li class="first"><a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/">Home</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/">My Account</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/course/view.php?id=11">OCPJP 6 - Exam Simulator</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> <a onclick="this.target=&#39;_top&#39;" href="http://www.whizlabs.com/examprep/mod/quiz/view.php?id=2204">Practice Test III</a></li><li class="first"> <span class="accesshide ">/&nbsp;</span><span class="arrow sep">»</span> Review of attempt 1</li></ul>			<div class="navbutton">
				</div>  
  
  <div style="float:right; margin-right:60px;font-size:12px; font-weight:bold; color:#0460AD;">
  	</div>
  </div>

  <div id="navi2">
  <a href="http://www.whizlabs.com/examprep/eddy_report/performance_trak.php?cid=11" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(&#39;Image1&#39;,&#39;&#39;,&#39;http://www.whizlabs.com/examprep/theme/ability-to-learn/images/layerrollov.gif&#39;,1)"><img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/performace_history.gif" name="Image1" width="125" height="32" border="0" id="Image1"></a></div>
    <!-- END OF HEADER -->
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div><h2 class="main">Practice Test III</h2><h2 class="main">Review of attempt 1</h2>




<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2204"><input type="submit" value="Finish review"></div></form></div></div>
<table class="generaltable generalbox quizreviewsummary"><tbody>
<tr><th scope="row" class="cell">Started on</th><td class="cell">Sunday,  18 December 2011, 10:33 AM</td></tr>
<tr><th scope="row" class="cell">Completed on</th><td class="cell">Sunday,  18 December 2011, 12:51 PM</td></tr>
<tr><th scope="row" class="cell">Time taken</th><td class="cell">2 hours 17 mins</td></tr>
<tr><th scope="row" class="cell">Grade</th><td class="cell"><b>34.83</b> out of a maximum of 60 (<b>58</b>%)</td></tr>
<tr><th scope="row" class="cell">Feedback</th><td class="cell"><p>FAIL: You need to study more!</p></td></tr>
</tbody></table>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%201%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16284" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                1      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output of the following code. <br><br>String thePattern = "ill\\d(?i)"; <br> Pattern pattern = Pattern.compile(thePattern); <br>String target = "Jack and JILL1 WENT UP THE hill2"; <br>Matcher matcher = pattern.matcher(target); System.out.println(matcher.replaceAll("xxxx") );</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16284_61907" name="resp16284_" type="radio" value="61907">        </td>
        <td class="c1 text ">
          <label for="resp16284_61907">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16284_61908" name="resp16284_" type="radio" value="61908">        </td>
        <td class="c1 text ">
          <label for="resp16284_61908">
            <span class="anun">b<span class="anumsep">.</span></span> Exception at runtime .            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16284_61909" name="resp16284_" type="radio" value="61909">        </td>
        <td class="c1 text correct">
          <label for="resp16284_61909">
            <span class="anun">c<span class="anumsep">.</span></span> Jack and Jxxxx WENT UP THE hxxxx.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16284_61910" name="resp16284_" type="radio" value="61910">        </td>
        <td class="c1 text ">
          <label for="resp16284_61910">
            <span class="anun">d<span class="anumsep">.</span></span> Jack and xxxx WENT UP THE xxxx.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C <br><br>Explanation: <br>Here we compile the regular expression string using the Pattern class, use the Pattern class to get a Matcher object, and call methods on the Matcher to get at any matches. <br><br>The regular expression "ill\\d" matches 'ill' words that end with a digit. The expression "(?i)" causes the case to be ignored. So both uppercase and lowercase versions of 'ill' can match. The replaceAll() method of the Matcher class takes a replacement string and replaces all matches with it. <br><br>Want to know more ? Check out: <br><a href="http://java.sun.com/docs/books/tutorial/extra/regex/pattern.html" target="_blank">http://java.sun.com/docs/books/tutorial/extra/regex/pattern.html </a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%202%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16285" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                2      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the option that will compile without any errors.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16285_61911" name="resp16285_" type="radio" value="61911">        </td>
        <td class="c1 text ">
          <label for="resp16285_61911">
            <span class="anun">a<span class="anumsep">.</span></span> new DateFormat(DateFormat.LONG, Locale.FRANCE).format(new Date());            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16285_61912" name="resp16285_" checked="checked" type="radio" value="61912">        </td>
        <td class="c1 text correct">
          <label for="resp16285_61912">
            <span class="anun">b<span class="anumsep">.</span></span> DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE).format(new Date());            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16285_61913" name="resp16285_" type="radio" value="61913">        </td>
        <td class="c1 text ">
          <label for="resp16285_61913">
            <span class="anun">c<span class="anumsep">.</span></span> DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE).parse(new Date());            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16285_61914" name="resp16285_" type="radio" value="61914">        </td>
        <td class="c1 text ">
          <label for="resp16285_61914">
            <span class="anun">d<span class="anumsep">.</span></span> new DateFormat(DateFormat.LONG, Locale.FRANCE).parse(new Date());            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B <br><br>Explanation: <br>DateFormat is an abstract class for date/time formatting subclasses which formats and parses dates or time in a language-independent manner. <br><br>Every locale has four default formats for formatting and parsing dates. They are called SHORT, MEDIUM, LONG, and FULL. <br><br>The SHORT format consists entirely of numbers while the FULL format contains most of the date components. <br><br>There is also a default format called DEFAULT and is the same as MEDIUM. <br><br><br>More about Locale class is available at: <br><a target="_blank" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Locale.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Locale.html </a><br><a target="_blank" href="http://java.sun.com/docs/books/tutorial/i18n/">http://java.sun.com/docs/books/tutorial/i18n/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%203%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16286" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                3      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the correct options.<br>(Choose three options)<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16286_61915" name="resp16286_61915" type="checkbox" value="61915">        </td>
        <td class="c1 text ">
          <label for="resp16286_61915">
            <span class="anun">a<span class="anumsep">.</span></span> Changes the current working directory : changeWorkingDirectory().            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16286_61916" name="resp16286_61916" type="checkbox" value="61916">        </td>
        <td class="c1 text ">
          <label for="resp16286_61916">
            <span class="anun">b<span class="anumsep">.</span></span> Deletes a file : remove() .            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16286_61917" name="resp16286_61917" type="checkbox" value="61917">        </td>
        <td class="c1 text correct">
          <label for="resp16286_61917">
            <span class="anun">c<span class="anumsep">.</span></span> Creates a file : createNewFile().            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16286_61918" name="resp16286_61918" checked="checked" type="checkbox" value="61918">        </td>
        <td class="c1 text correct">
          <label for="resp16286_61918">
            <span class="anun">d<span class="anumsep">.</span></span> Renames a file : renameTo().            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16286_61919" name="resp16286_61919" type="checkbox" value="61919">        </td>
        <td class="c1 text correct">
          <label for="resp16286_61919">
            <span class="anun">e<span class="anumsep">.</span></span> Makes a directory : mkdir().            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C, D, E <br><br>Explanation: <br>The File class does not provide any methods to change the current working directory. <br>The delete() method attempts to delete a file or a directory. <br> The createNewFile() method creates a new empty disk file. <br>The renameTo() method can be used to rename a file or a directory. <br>The mkdir() method attempts to create a new directory. <br><br>Reference: <br><a target="_blank" href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html">http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html</a>      </div>
        <div class="grading">
      <div class="correctness  partiallycorrect">Partially correct</div><div class="gradingdetails">Marks for this submission: 0.33/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%204%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16287" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                4      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the output of the following code. <br><br>public class T <br>{ <br>
<div style="margin-left: 40px;">public static void main (String[ ] args) throws Exception <br></div>
<div style="margin-left: 40px;">{ <br></div>
<div style="margin-left: 80px;">String s="it"; <br> boolean b=false; <br>System.out.format("The value is %3$.2f. That is %2$b ,isn't %1$s ?", s, b , 0.345); <br></div>
<div style="margin-left: 40px;">}<br></div>}<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16287_61920" name="resp16287_" type="radio" value="61920">        </td>
        <td class="c1 text ">
          <label for="resp16287_61920">
            <span class="anun">a<span class="anumsep">.</span></span> Compilation error.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16287_61921" name="resp16287_" type="radio" value="61921">        </td>
        <td class="c1 text ">
          <label for="resp16287_61921">
            <span class="anun">b<span class="anumsep">.</span></span> Exception at runtime .            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16287_61922" name="resp16287_" checked="checked" type="radio" value="61922">        </td>
        <td class="c1 text correct">
          <label for="resp16287_61922">
            <span class="anun">c<span class="anumsep">.</span></span> The value is 0.35. That is false ,isn't it ?            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16287_61923" name="resp16287_" type="radio" value="61923">        </td>
        <td class="c1 text ">
          <label for="resp16287_61923">
            <span class="anun">d<span class="anumsep">.</span></span> The value is 0.345. That is false ,isn't it ?            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16287_61924" name="resp16287_" type="radio" value="61924">        </td>
        <td class="c1 text ">
          <label for="resp16287_61924">
            <span class="anun">e<span class="anumsep">.</span></span> The value is it. That is false ,isn't 0.345 ?            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : C <br><br>Explanation: <br>The Formatter class provides support for layout justification and alignment, common formats for numeric, string, and date/time data, and locale-specific output. <br><br>The PrintStream class (of which System.out is an instance) has two format methods. <br><br><br>The format(String format, Object... args) method writes a formatted string to this object's destination using the specified format string and arguments. <br><br><br>The %s format string is used for formatting the value supplied as a String and printing it. <br><br>The %b format is for boolean values and %f for floating point values. <br><br><br>The $ notation is used to re-order the arguments according to the specified integer, that is 3$ stands for argument no. 3, 2$ stands for argument no. 2, and so on. <br><br>To know more about the Formatter, refer to: <br><a target="_blank" href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/logging/Formatter.html">http://download.oracle.com/javase/1.5.0/docs/api/java/util/logging/Formatter.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%205%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5389" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                5      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code?<br><br> String s1 = new String("Bicycle");<br><br> String s2 = new String("bicycle");<br><br> System.out.println(s1.equals(s2)==s2.equals(s1));</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5389_22942" name="resp5389_" type="radio" value="22942">        </td>
        <td class="c1 text ">
          <label for="resp5389_22942">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5389_22943" name="resp5389_" checked="checked" type="radio" value="22943">        </td>
        <td class="c1 text correct">
          <label for="resp5389_22943">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "true"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5389_22944" name="resp5389_" type="radio" value="22944">        </td>
        <td class="c1 text ">
          <label for="resp5389_22944">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "false"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5389_22945" name="resp5389_" type="radio" value="22945">        </td>
        <td class="c1 text ">
          <label for="resp5389_22945">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "false==false"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5389_22946" name="resp5389_" type="radio" value="22946">        </td>
        <td class="c1 text ">
          <label for="resp5389_22946">
            <span class="anun">e<span class="anumsep">.</span></span> Prints "true==true"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br> The given expression will print true not only for the given strings but for any two strings you might choose. <br><br>The equals method is symmetric: for any reference values x and y, x.equals( y ) should return true if and only if y.equals(x) returns true. So in this case, s1.equals(s2) gives false and s2.equals(s1) also gives false. The result of (false==false) is true. So the output is true. <br><br>More information is available at: <br><a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html%20">http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html </a><br><a href="http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html-12104"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%206%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5390" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                6      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following, if inserted independently at the indicated point in the main method, will print true? Select three choices.<br><br> public class Test <br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px;"> Boolean b=new Boolean("TRUE");<br> boolean b1=true; <br>// insert code here<br> System.out.print("true"); <br></div>}<br></div> }<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5390_22947" name="resp5390_22947" type="checkbox" value="22947">        </td>
        <td class="c1 text correct">
          <label for="resp5390_22947">
            <span class="anun">a<span class="anumsep">.</span></span> if(b.booleanValue()==b1)            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5390_22948" name="resp5390_22948" type="checkbox" value="22948">        </td>
        <td class="c1 text ">
          <label for="resp5390_22948">
            <span class="anun">b<span class="anumsep">.</span></span> if(b.booleanValue()=="true")            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5390_22949" name="resp5390_22949" checked="checked" type="checkbox" value="22949">        </td>
        <td class="c1 text ">
          <label for="resp5390_22949">
            <span class="anun">c<span class="anumsep">.</span></span> if(b.equals("true"))            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5390_22950" name="resp5390_22950" type="checkbox" value="22950">        </td>
        <td class="c1 text ">
          <label for="resp5390_22950">
            <span class="anun">d<span class="anumsep">.</span></span> if(b1=="true")            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5390_22951" name="resp5390_22951" type="checkbox" value="22951">        </td>
        <td class="c1 text correct">
          <label for="resp5390_22951">
            <span class="anun">e<span class="anumsep">.</span></span> if(b==b1)            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5390_22952" name="resp5390_22952" type="checkbox" value="22952">        </td>
        <td class="c1 text correct">
          <label for="resp5390_22952">
            <span class="anun">f<span class="anumsep">.</span></span> if(b.equals(b1))            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, E, and F are the correct answers. <br><br>The booleanValue() method of the Boolean class returns the encapsulated boolean value of the Boolean object, which is true in this case. Comparing true with b1, which is also true, results in true. So choice A is correct. <br><br>In choice F, b1 is autoboxed into a Boolean object of the same value, so b.equals(b1) returns true. <br><br>In choice E, b is unboxed into a boolean primitive of value true. Comparing the true values of both boolean primitives yields true. <br><br>Choice B will not compile because boolean type and String type cannot be compared. <br><br>Choice C prints false as a Boolean object and a String object cannot be the same. <br><br>Choice D will not compile because the Boolean object and the String object cannot be compared with the == operator.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%207%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5391" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                7      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>String s=new String("hello");<br><br> StringBuffer sb=new StringBuffer("hello");<br> <br>System.out.println(s.equals(sb));</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5391_22953" name="resp5391_" type="radio" value="22953">        </td>
        <td class="c1 text ">
          <label for="resp5391_22953">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error: String and StringBuffer objects cannot be compared            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5391_22954" name="resp5391_" type="radio" value="22954">        </td>
        <td class="c1 text ">
          <label for="resp5391_22954">
            <span class="anun">b<span class="anumsep">.</span></span> ClassCastException: String and StringBuffer objects cannot be compared            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5391_22955" name="resp5391_" type="radio" value="22955">        </td>
        <td class="c1 text ">
          <label for="resp5391_22955">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "true"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5391_22956" name="resp5391_" checked="checked" type="radio" value="22956">        </td>
        <td class="c1 text correct">
          <label for="resp5391_22956">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "false"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> The equals method does not cause any compiler error or exception if the invoking object and the argument are objects of different classes. This is because the argument to equals method is of type Object, so any object can be passed. Thus choices A and B are incorrect.<br><br>However, the method must return false, if the objects are not of the same class. <br><br>So choice D is correct while choice C is incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%208%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5392" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                8      </div>
      </div>
  <div class="content">
    <div class="qtext">
  You want a floating point number to be formatted in Italian format. Which of the following code snippets can help you achieve this?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5392_22957" name="resp5392_" type="radio" value="22957">        </td>
        <td class="c1 text ">
          <label for="resp5392_22957">
            <span class="anun">a<span class="anumsep">.</span></span> NumberFormat nf=new NumberFormat(Locale.Italy);<br>&nbsp;&nbsp;&nbsp;&nbsp;String s=nf.format(123.45);            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5392_22958" name="resp5392_" type="radio" value="22958">        </td>
        <td class="c1 text correct">
          <label for="resp5392_22958">
            <span class="anun">b<span class="anumsep">.</span></span> NumberFormat nf=NumberFormat.getInstance(Locale.Italy);<br>&nbsp;&nbsp;&nbsp;&nbsp;String s=nf.format(123.45);            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5392_22959" name="resp5392_" checked="checked" type="radio" value="22959">        </td>
        <td class="c1 text ">
          <label for="resp5392_22959">
            <span class="anun">c<span class="anumsep">.</span></span> NumberFormat nf=NumberFormat.getInstance();<br>&nbsp;&nbsp;&nbsp;&nbsp;String s=nf.format(123.45,Locale.Italy);            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5392_22960" name="resp5392_" type="radio" value="22960">        </td>
        <td class="c1 text ">
          <label for="resp5392_22960">
            <span class="anun">d<span class="anumsep">.</span></span> NumberFormat nf=new NumberFormat();<br>&nbsp;&nbsp;&nbsp;&nbsp;String s=nf.format(123.45,Locale.Italy);            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br> You can use the following factory method when a Locale other than the default Locale is to be used. <br><br>
<div style="margin-left: 40px;">public static NumberFormat.getInstance(Locale locale) <br></div><br>The format method just takes the number as the argument and returns the formatter string. So choices C and D are incorrect. <br><br>Choice A is incorrect because NumberFormat is an abstract class and cannot be instantiated using the new operator. <br><br>Reference: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html">http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%209%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5393" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                9      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result when the following code is executed?<br><br> String s = "howzzat";<br>Scanner scanner = new Scanner(s);<br> scanner.useDelimiter("wz");<br> scanner.next();<br> System.out.println(scanner.next());</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5393_22961" name="resp5393_" type="radio" value="22961">        </td>
        <td class="c1 text ">
          <label for="resp5393_22961">
            <span class="anun">a<span class="anumsep">.</span></span> No output            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5393_22962" name="resp5393_" type="radio" value="22962">        </td>
        <td class="c1 text ">
          <label for="resp5393_22962">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "wz"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5393_22963" name="resp5393_" type="radio" value="22963">        </td>
        <td class="c1 text ">
          <label for="resp5393_22963">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "wzz"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5393_22964" name="resp5393_" type="radio" value="22964">        </td>
        <td class="c1 text ">
          <label for="resp5393_22964">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "ho"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5393_22965" name="resp5393_" checked="checked" type="radio" value="22965">        </td>
        <td class="c1 text correct">
          <label for="resp5393_22965">
            <span class="anun">e<span class="anumsep">.</span></span> Prints "zat"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice E is the correct answer.<br><br> When the given code is executed, the string "zat" is printed to the standard output. The java.util.Scanner can be used to break the contents of the given string into tokens using a delimiter pattern. Here you set the delimiter to "wz" through the useDelimiter() method of Scanner.<br><br> The first invocation of the next() method returns "ho" and the second invocation returns "zat" which is then printed out. Since choice E is correct, the other choices are automatically incorrect. <br><br>References: <br><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html </a><br><a href="http://java.sun.com/developer/JDCTechTips/2004/tt1201.html">http://java.sun.com/developer/JDCTechTips/2004/tt1201.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2010%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5394" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                10      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following compiles correctly if f is an instance of the File class? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5394_22966" name="resp5394_22966" checked="checked" type="checkbox" value="22966">        </td>
        <td class="c1 text correct">
          <label for="resp5394_22966">
            <span class="anun">a<span class="anumsep">.</span></span> String[] s =f.list();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5394_22967" name="resp5394_22967" type="checkbox" value="22967">        </td>
        <td class="c1 text ">
          <label for="resp5394_22967">
            <span class="anun">b<span class="anumsep">.</span></span> File[] files=f.list();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5394_22968" name="resp5394_22968" type="checkbox" value="22968">        </td>
        <td class="c1 text correct">
          <label for="resp5394_22968">
            <span class="anun">c<span class="anumsep">.</span></span> File[] files=f.listFiles();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5394_22969" name="resp5394_22969" type="checkbox" value="22969">        </td>
        <td class="c1 text ">
          <label for="resp5394_22969">
            <span class="anun">d<span class="anumsep">.</span></span> List files=f.listFiles();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and C are the correct answers.<br><br> The File class defines a list() method and a listFiles() method. <br><br>The list() method returns an array of Strings containing the names of the files and directories in the directory denoted by the abstract pathname represented by the File object. <br><br>The listFiles() method returns an array of File objects denoting the files and directories in the directory denoted by the abstract pathname represented by the File object.      </div>
        <div class="grading">
      <div class="correctness  partiallycorrect">Partially correct</div><div class="gradingdetails">Marks for this submission: 0.5/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2011%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16288" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                11      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the correct options.<br>(Choose two options)<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16288_61925" name="resp16288_61925" type="checkbox" value="61925">        </td>
        <td class="c1 text ">
          <label for="resp16288_61925">
            <span class="anun">a<span class="anumsep">.</span></span> Does not allow duplicates, no ordering : LinkedList.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16288_61926" name="resp16288_61926" checked="checked" type="checkbox" value="61926">        </td>
        <td class="c1 text correct">
          <label for="resp16288_61926">
            <span class="anun">b<span class="anumsep">.</span></span> Does not allow duplicate keys, may use last accessed order : LinkedHashMap.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16288_61927" name="resp16288_61927" checked="checked" type="checkbox" value="61927">        </td>
        <td class="c1 text correct">
          <label for="resp16288_61927">
            <span class="anun">c<span class="anumsep">.</span></span> Allows random access, synchronized methods : Vector.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16288_61928" name="resp16288_61928" type="checkbox" value="61928">        </td>
        <td class="c1 text ">
          <label for="resp16288_61928">
            <span class="anun">d<span class="anumsep">.</span></span> Unique keys mapped to value objects, sorted order of keys : HashMap.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : B,C <br><br>Explanation: Set types do not allow duplicate elements. <br><br>HashSet is the most efficient Set class; it does not provide any ordering for its elements. <br><br>LinkedHashMap is a Map class, which allows two types of ordering for its elements, insertion order or last accessed order. <br><br>Vector is a List type, which is similar to ArrayList except that its methods are synchronized, whereas the methods of ArrayList are not. <br><br>TreeMap maps unique keys to non-unique values; the pairs are sorted in the order of keys.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2012%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5388" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                12      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code?<br><br> ConcurrentNavigableMap myMap = new ConcurrentSkipListMap();<br> myMap.put("ab", 10);<br> myMap.put("cd", 5);<br> myMap.put("ca", 30);<br> myMap.put("c", 30);<br> myMap.put("az", 20);<br> NavigableMap myMap2 = myMap.tailMap("c", true);<br> System.out.println(myMap.size() + " " + myMap2.size());<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22938" name="resp5388_" type="radio" value="22938">        </td>
        <td class="c1 text ">
          <label for="resp5388_22938">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22939" name="resp5388_" type="radio" value="22939">        </td>
        <td class="c1 text ">
          <label for="resp5388_22939">
            <span class="anun">b<span class="anumsep">.</span></span> Exception            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22940" name="resp5388_" checked="checked" type="radio" value="22940">        </td>
        <td class="c1 text correct">
          <label for="resp5388_22940">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 5 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5388_22941" name="resp5388_" type="radio" value="22941">        </td>
        <td class="c1 text ">
          <label for="resp5388_22941">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 5 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is correct.<br><br> The tailMap(fromKey) method defined in NavigableMap returns a view of the portion of this map whose keys are greater than or equal to fromKey. Here, the key is "c", hence the map view returned contains "c","ca" and "cd". <br><br>Since the main map contains 5 elements and the view contains 3 elements, the output is 5 3. Since the code compiles and runs correctly, all the other choices are incorrect. <br><br>For more information, refer to <br><a href="http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html">http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2013%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5396" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                13      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the return type of the firstEntry() method in the NavigableMap interface?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5396_22975" name="resp5396_" type="radio" value="22975">        </td>
        <td class="c1 text ">
          <label for="resp5396_22975">
            <span class="anun">a<span class="anumsep">.</span></span> String            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5396_22976" name="resp5396_" checked="checked" type="radio" value="22976">        </td>
        <td class="c1 text ">
          <label for="resp5396_22976">
            <span class="anun">b<span class="anumsep">.</span></span> Object            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5396_22977" name="resp5396_" type="radio" value="22977">        </td>
        <td class="c1 text ">
          <label for="resp5396_22977">
            <span class="anun">c<span class="anumsep">.</span></span> Map            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5396_22978" name="resp5396_" type="radio" value="22978">        </td>
        <td class="c1 text correct">
          <label for="resp5396_22978">
            <span class="anun">d<span class="anumsep">.</span></span> Map.Entry            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is correct. <br><br>The firstEntry() method returns a key-value mapping associated with the least key in this map, or null if the map is empty. It returns an entry of type Map.Entry with the least key, or null if this map is empty. Since choice D is correct, all the other choices are automatically incorrect. <br><br>For more information, check out the following link.<br> <a href="http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html">http://java.sun.com/javase/6/docs/api/java/util/NavigableMap.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2014%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5397" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                14      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which interface defines the int compare(Object, Object) method?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22979" name="resp5397_" checked="checked" type="radio" value="22979">        </td>
        <td class="c1 text correct">
          <label for="resp5397_22979">
            <span class="anun">a<span class="anumsep">.</span></span> Comparator            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22980" name="resp5397_" type="radio" value="22980">        </td>
        <td class="c1 text ">
          <label for="resp5397_22980">
            <span class="anun">b<span class="anumsep">.</span></span> Comparable            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22981" name="resp5397_" type="radio" value="22981">        </td>
        <td class="c1 text ">
          <label for="resp5397_22981">
            <span class="anun">c<span class="anumsep">.</span></span> SortedSet            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5397_22982" name="resp5397_" type="radio" value="22982">        </td>
        <td class="c1 text ">
          <label for="resp5397_22982">
            <span class="anun">d<span class="anumsep">.</span></span> TreeMap            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The java.lang.Comparator interface defines the compare method whose signature is <br><br>
<div style="margin-left: 40px;">int compare(Object o1, Object o2) <br></div><br>A comparator can be used to define total ordering of objects in a collection, based on the result of the compare method. So choice A is correct. <br><br>Comparable interface imposes a total ordering on the objects of each class that implements it. The method defined by it is int compareTo(Object). So choice B is incorrect. <br><br>The SortedSet interface represents a Set, whose elements can be iterated in a sorted order. It does not define the compare method. So choice C is incorrect. <br><br>Choice D is also incorrect since TreeMap is a class and not an interface. Moreover, it does not define any method called compare. <br><br>Reference: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2015%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5398" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                15      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you try to compile and run the following code? <br><br>1. import java.util.*; <br>2. public class MapTest <br>3. { <br>4. public static void main(String[] args) <br>5. { <br>6. Object obj = new LinkedHashMap(); <br>7. if(obj instanceof Collection) <br>8. System.out.print("For "); <br>9. if(obj instanceof Map) <br>10. System.out.print("A Few "); <br>11. if(obj instanceof LinkedList) <br>12. System.out.print("Dollars More "); <br>13. if(obj instanceof HashMap) <br>14. System.out.print("Good Men"); <br>15. } <br>16. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5398_22983" name="resp5398_" checked="checked" type="radio" value="22983">        </td>
        <td class="c1 text correct">
          <label for="resp5398_22983">
            <span class="anun">a<span class="anumsep">.</span></span> It will print - A Few Good Men            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5398_22984" name="resp5398_" type="radio" value="22984">        </td>
        <td class="c1 text ">
          <label for="resp5398_22984">
            <span class="anun">b<span class="anumsep">.</span></span> It will print - For A Few Good Men            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5398_22985" name="resp5398_" type="radio" value="22985">        </td>
        <td class="c1 text ">
          <label for="resp5398_22985">
            <span class="anun">c<span class="anumsep">.</span></span> It will print - For A Few Dollars More Good Men            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5398_22986" name="resp5398_" type="radio" value="22986">        </td>
        <td class="c1 text ">
          <label for="resp5398_22986">
            <span class="anun">d<span class="anumsep">.</span></span> It will print - For A Few Dollars More            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5398_22987" name="resp5398_" type="radio" value="22987">        </td>
        <td class="c1 text ">
          <label for="resp5398_22987">
            <span class="anun">e<span class="anumsep">.</span></span> It will print - For A Few            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5398_22988" name="resp5398_" type="radio" value="22988">        </td>
        <td class="c1 text ">
          <label for="resp5398_22988">
            <span class="anun">f<span class="anumsep">.</span></span> It will print - A Few Dollars More            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The code will compile and print - A Few Good Men. The LinkedHashMap class extends the HashMap class, which in turn implements the Map interface. It is also important to understand that the Map interface does not extend the interface Collection. Here is the hierarchy for the class LinkedHashMap- <br><br> java.lang.Object <br>
<div style="margin-left: 40px;">|<br> +-java.util.AbstractMap (implements Map) <br>
  <div style="margin-left: 40px;">|<br> +-java.util.HashMap (implements Map) <br>
    <div style="margin-left: 40px;">|<br> +-java.util.LinkedHashMap (implements Map) <br></div></div></div><br>Let's look at the execution of this code now. At line 6, a new LinkedHashMap object is created, since LinkedHashMap does not implement the Collection interface directly or indirectly, the instanceof check at line 7 returns false. <br><br>Next, since the parent class of the LinkedHashMap class implements Map, the instanceof operator in line 9 returns true and the code at line 10 prints - "A Few " (without the quotes). Since the LinkedHashMap class does not extend the LinkedList class in any way, the instanceof check at line 11 returns false and the print statement at line 12 is not executed. <br><br>The instanceof check at line 13 succeeds because the LinkedHashMap class extends HashMap; hence the statement at line 14 prints "Good Men". Thus the entire code prints - A Few Good Men. Want to know more? <br><br>You can read more about the new collection class LinkedHashMap and its usage at - <br><a href="http://www-106.ibm.com/developerworks/java/library/j-mer0821/">http://www-106.ibm.com/developerworks/java/library/j-mer0821/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2016%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5399" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                16      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing the following code?<br><br> 1. Vector v=new Vector&lt;Integer&gt;(); <br>2. v.add(18); <br>3. v.add(20); <br>4. v.add(12); <br>5. for(int i : v) <br>6. System.out.print(i+" ");</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22989" name="resp5399_" type="radio" value="22989">        </td>
        <td class="c1 text ">
          <label for="resp5399_22989">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22990" name="resp5399_" type="radio" value="22990">        </td>
        <td class="c1 text ">
          <label for="resp5399_22990">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at lines 2, 3, and 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22991" name="resp5399_" checked="checked" type="radio" value="22991">        </td>
        <td class="c1 text correct">
          <label for="resp5399_22991">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5399_22992" name="resp5399_" type="radio" value="22992">        </td>
        <td class="c1 text ">
          <label for="resp5399_22992">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 18 20 12            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The code does not compile at line 5 because iterating through v gives elements of type Object, and Object type cannot be assigned to int or Integer variables. This happens because the declared type of v is Vector and not Vector&lt;Integer&gt;. <br><br>Choice A is incorrect because line 1 compiles without errors, it is allowed to assign generic types to raw types. <br><br>Choice B is incorrect because lines 2, 3, and 4 do compile fine, the int type values get autoboxed to Integer. <br><br>Since choice C is correct, choice D is automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2017%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5400" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                17      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following classes override the hashCode() method defined in java.lang.Object class? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5400_22993" name="resp5400_22993" checked="checked" type="checkbox" value="22993">        </td>
        <td class="c1 text correct">
          <label for="resp5400_22993">
            <span class="anun">a<span class="anumsep">.</span></span> java.lang.String            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5400_22994" name="resp5400_22994" type="checkbox" value="22994">        </td>
        <td class="c1 text ">
          <label for="resp5400_22994">
            <span class="anun">b<span class="anumsep">.</span></span> java.lang.StringBuffer            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5400_22995" name="resp5400_22995" type="checkbox" value="22995">        </td>
        <td class="c1 text correct">
          <label for="resp5400_22995">
            <span class="anun">c<span class="anumsep">.</span></span> java.lang.Byte            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5400_22996" name="resp5400_22996" type="checkbox" value="22996">        </td>
        <td class="c1 text ">
          <label for="resp5400_22996">
            <span class="anun">d<span class="anumsep">.</span></span> java.lang.Number            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5400_22997" name="resp5400_22997" checked="checked" type="checkbox" value="22997">        </td>
        <td class="c1 text ">
          <label for="resp5400_22997">
            <span class="anun">e<span class="anumsep">.</span></span> Only choice A is correct            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and C are the correct answers.<br><br> The java.lang.String and java.lang.Byte classes override the equals() and hashCode() methods of the java.lang.Object class to provide their own implementation. On the other hand, the java.lang.StringBuffer and java.lang.Number classes do not override these methods and inherit their implementation from the java.lang.Object superclass. Hence, choices B and D are incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2018%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5401" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                18      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which collection implementation is suitable for maintaining an ordered sequence of objects when objects are frequently inserted and removed from the middle of the sequence?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5401_22998" name="resp5401_" checked="checked" type="radio" value="22998">        </td>
        <td class="c1 text ">
          <label for="resp5401_22998">
            <span class="anun">a<span class="anumsep">.</span></span> TreeMap            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5401_22999" name="resp5401_" type="radio" value="22999">        </td>
        <td class="c1 text ">
          <label for="resp5401_22999">
            <span class="anun">b<span class="anumsep">.</span></span> Vector            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5401_23000" name="resp5401_" type="radio" value="23000">        </td>
        <td class="c1 text ">
          <label for="resp5401_23000">
            <span class="anun">c<span class="anumsep">.</span></span> ArrayList            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5401_23001" name="resp5401_" type="radio" value="23001">        </td>
        <td class="c1 text correct">
          <label for="resp5401_23001">
            <span class="anun">d<span class="anumsep">.</span></span> LinkedList            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> When objects are frequently inserted and deleted from the middle of the sequence, LinkedList gives the best performance. TreeMap does not maintain an ordered sequence of objects. So choice A is incorrect. <br><br>Vector and ArrayList require shifting of objects on insertion and deletion, while LinkedList does not. So choices B and C are incorrect. <br><br>Reference:<br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2019%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5402" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                19      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>1. ArrayList&lt;Double&gt; a=new ArrayList&lt;Double&gt;(); <br>2. a.add(new Integer(4)); <br>3. System.out.println(a);</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5402_23002" name="resp5402_" checked="checked" type="radio" value="23002">        </td>
        <td class="c1 text correct">
          <label for="resp5402_23002">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5402_23003" name="resp5402_" type="radio" value="23003">        </td>
        <td class="c1 text ">
          <label for="resp5402_23003">
            <span class="anun">b<span class="anumsep">.</span></span> ClassCastException at line 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5402_23004" name="resp5402_" type="radio" value="23004">        </td>
        <td class="c1 text ">
          <label for="resp5402_23004">
            <span class="anun">c<span class="anumsep">.</span></span> Compiles and runs fine printing [4]            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5402_23005" name="resp5402_" type="radio" value="23005">        </td>
        <td class="c1 text ">
          <label for="resp5402_23005">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles and runs fine printing [4.0]            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> Using generics, it is possible to marks collections as being restricted to contain a particular data type. The code does not compile at line 2 because we are trying to add an Integer object in an ArrayList of type Double. <br><br>Generic types offer this compile time type-checking to avoid runtime exceptions from getting thrown. So choice B is incorrect. <br><br>Since the code does not even compile, choices C and D are also incorrect. <br><br>For more information, check out: <br><a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2020%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5403" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                20      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the following code line. <br><br>Map&lt;Integer,String&gt; map = new HashMap&lt;Integer,String&gt;();<br><br> Which of the following are legal? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5403_23006" name="resp5403_23006" type="checkbox" value="23006">        </td>
        <td class="c1 text correct">
          <label for="resp5403_23006">
            <span class="anun">a<span class="anumsep">.</span></span> for(Map.Entry pairs : map.entrySet()){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5403_23007" name="resp5403_23007" type="checkbox" value="23007">        </td>
        <td class="c1 text correct">
          <label for="resp5403_23007">
            <span class="anun">b<span class="anumsep">.</span></span> Iterator i=map.entrySet().iterator();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5403_23008" name="resp5403_23008" type="checkbox" value="23008">        </td>
        <td class="c1 text ">
          <label for="resp5403_23008">
            <span class="anun">c<span class="anumsep">.</span></span> Iterator i=map.iterator();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5403_23009" name="resp5403_23009" type="checkbox" value="23009">        </td>
        <td class="c1 text correct">
          <label for="resp5403_23009">
            <span class="anun">d<span class="anumsep">.</span></span> Iterator&lt;Map.Entry&lt;Integer,String&gt;&gt; i=map.entrySet().iterator();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5403_23010" name="resp5403_23010" type="checkbox" value="23010">        </td>
        <td class="c1 text ">
          <label for="resp5403_23010">
            <span class="anun">e<span class="anumsep">.</span></span> Iterator&lt;Map.Entry&gt; i=map.entrySet().iterator();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, B, and D are the correct answers.<br><br> A Map interface is implemented by an object that maps unique keys to values. Here, the key is of Integer type and the value of String type. The HashMap class is an efficient implementation of the Map interface, which does not guarantee any ordering for the keys. The entrySet() method of Map returns a Set view of the mappings contained in this Map. Each element in the Set is a Map.Entry, from which the key and the value can be obtained. <br><br>Choice A is correct because enhanced for loop can be used to iterate through all collection types, including sets. <br><br>Choice B is correct because the iterator() method of a set returns the Iterator object which can be used to traverse the set. <br><br>Choice C is incorrect because the Map interface does not define an iterator() method. <br><br>Choice D is correct because the objects iterated upon are of type Map.Entry&lt;Integer,String&gt;. <br><br>Choice E is incorrect because the object type is specified as Map.Entry instead of Map.Entry&lt;Integer,String&gt;. <br><br>For more information, check out:<br> <a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2021%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5404" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                21      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code? <br><br>import java.util.*; <br><br>class MyClass implements java.io.Serializable<br>{ <br>
<div style="margin-left: 40px;">int i; <br>MyClass(int i)<br>{ <br>
  <div style="margin-left: 40px;">this.i=i; <br></div>}<br> public String toString()<br>{<br>
  <div style="margin-left: 40px;"> return(""+i); <br></div>} <br></div>} <br><br>public class TreeTest <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px;"> Set&lt;MyClass&gt; s=new TreeSet&lt;MyClass&gt;();<br> s.add(new MyClass(2)); <br>s.add(new MyClass(3)); <br>s.add(new MyClass(1));<br> for(MyClass m : s) <br>
    <div style="margin-left: 40px;">System.out.println(m); <br></div></div>} <br></div>}<input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5404_23011" name="resp5404_" type="radio" value="23011">        </td>
        <td class="c1 text ">
          <label for="resp5404_23011">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5404_23012" name="resp5404_" type="radio" value="23012">        </td>
        <td class="c1 text correct">
          <label for="resp5404_23012">
            <span class="anun">b<span class="anumsep">.</span></span> ClassCastException            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5404_23013" name="resp5404_" checked="checked" type="radio" value="23013">        </td>
        <td class="c1 text ">
          <label for="resp5404_23013">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 2 3 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
           <input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div>        </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5404_23014" name="resp5404_" type="radio" value="23014">        </td>
        <td class="c1 text ">
          <label for="resp5404_23014">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 1 2 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5404_23015" name="resp5404_" type="radio" value="23015">        </td>
        <td class="c1 text ">
          <label for="resp5404_23015">
            <span class="anun">e<span class="anumsep">.</span></span> Prints 3 2 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
      <div class="feedback">
      <input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div>    </div>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br> The add() method of TreeSet throws ClassCastException if the elements of the Set cannot be compared. For this, the element class needs to implement Comparable interface and override the compareTo() method. <br><br>Here the MyClass class does not implement Comparable, hence the error. There are no compiler errors in this code, so choice A is incorrect. <br><br>Since ClassCastException is thrown, no output is generated. So the other choices are also incorrect. <br><br>Reference:<br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/TreeSet.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/TreeSet.html</a><input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2022%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5405" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                22      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following will compile and run correctly? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5405_23016" name="resp5405_23016" type="checkbox" value="23016">        </td>
        <td class="c1 text correct">
          <label for="resp5405_23016">
            <span class="anun">a<span class="anumsep">.</span></span> List&lt;?&gt; l=new Vector&lt;String&gt;();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5405_23017" name="resp5405_23017" checked="checked" type="checkbox" value="23017">        </td>
        <td class="c1 text correct">
          <label for="resp5405_23017">
            <span class="anun">b<span class="anumsep">.</span></span> Map&lt;? extends Number, ? extends Number&gt; m1=new Hashtable&lt;Integer,Float&gt;();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5405_23018" name="resp5405_23018" checked="checked" type="checkbox" value="23018">        </td>
        <td class="c1 text ">
          <label for="resp5405_23018">
            <span class="anun">c<span class="anumsep">.</span></span> Map&lt;String, String&gt; m2=new Map&lt;String,String&gt;();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5405_23019" name="resp5405_23019" type="checkbox" value="23019">        </td>
        <td class="c1 text ">
          <label for="resp5405_23019">
            <span class="anun">d<span class="anumsep">.</span></span> Set&lt;String&gt; s=new LinkedHashSet&lt;String&gt;;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and B are the correct answers.<br> <br>The List interface is implemented by the Vector class. Hence, a List type variable can hold a reference to a Vector object. The wild card character (?) stands for an unknown type, which can legally hold any type. So it is legal to assign a collection of type Vector&lt;String&gt; to<span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;times new roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;" class="Apple-style-span"><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 13px;" class="Apple-style-span"><i><span class="Apple-converted-space"></span></i> List&lt;?&gt;. </span></span> So choice A is correct. <br><br>Hashtable implements the Map interface, so it is legal to assign a Hashtable object to a Map type. Both Integer and Float classes extend Number. The type of Map is declared as Map&lt;? extends Number, ? extends Number&gt;, so the key of the Hashtable object can be of Integer type, and the value of Float type. So choice B is also correct. <br><br>Map is an interface, so directly instantiating it is not allowed. Hence, choice C is incorrect. <br><br>Choice D is incorrect because the parentheses are missing at the end. The correct statement would be Set&lt;String&gt; s=new LinkedHashSet&lt;String&gt;(); <br><br>For more information, <br>check out: <a href="http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf">http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2023%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5406" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                23      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following methods must be implemented correctly by a class if the objects of the class are to behave properly and consistently with all Java collection types? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5406_23020" name="resp5406_23020" checked="checked" type="checkbox" value="23020">        </td>
        <td class="c1 text correct">
          <label for="resp5406_23020">
            <span class="anun">a<span class="anumsep">.</span></span> public int hashCode()            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5406_23021" name="resp5406_23021" type="checkbox" value="23021">        </td>
        <td class="c1 text ">
          <label for="resp5406_23021">
            <span class="anun">b<span class="anumsep">.</span></span> protected Object clone()            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5406_23022" name="resp5406_23022" type="checkbox" value="23022">        </td>
        <td class="c1 text ">
          <label for="resp5406_23022">
            <span class="anun">c<span class="anumsep">.</span></span> public String toString()            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5406_23023" name="resp5406_23023" checked="checked" type="checkbox" value="23023">        </td>
        <td class="c1 text correct">
          <label for="resp5406_23023">
            <span class="anun">d<span class="anumsep">.</span></span> public boolean equals(Object obj)            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5406_23024" name="resp5406_23024" type="checkbox" value="23024">        </td>
        <td class="c1 text ">
          <label for="resp5406_23024">
            <span class="anun">e<span class="anumsep">.</span></span> public long hashCode()            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and D are the correct answers.<br><br> The public int hashCode() and public boolean equals(Object obj) methods must be implemented correctly by a class if its objects have to behave consistently and properly with all Java collection classes and interfaces. <br><br>Also, note that the hashCode() method returns an int, and not long. Hence, choice E is incorrect. <br><br>Also, it is not mandatory to implement/override any other method so that the class behaves properly and consistently with all Java collection classes and interfaces. Let us understand why it is important to implement these methods correctly. The collection classes internally use these two methods of objects for performing various collection operations. If these methods are implemented incorrectly, you simply do not know how your class objects will behave when confronted to objects of other classes. <br><br>For an example, if your class violates the "reflexivity" rule which says that an object must be equal to itself, and then an instance of your class is added to a collection; the collection's contains() method would return false indicating that the collection did not contain the instance that you just added. <br><br>Also, whenever equals method is overridden in a class, it is necessary to override hashCode() method as well, as specified by the general contract of the hashCode() method. <br><br>Reference:<br> <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html">http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2024%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5409" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                24      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given that a static method doIt() in the Work class represents work to be done, which of the following blocks of code will succeed in starting a new thread that will do the work?</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5409_23035" name="resp5409_" checked="checked" type="radio" value="23035">        </td>
        <td class="c1 text correct">
          <label for="resp5409_23035">
            <span class="anun">a<span class="anumsep">.</span></span> Runnable r = new Runnable()<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br>     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void run() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{    <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Work.doIt();     <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}   <br> &nbsp;&nbsp;&nbsp;&nbsp;}; <br>&nbsp;&nbsp;&nbsp;&nbsp;Thread t = new Thread(r); <br>&nbsp;&nbsp;&nbsp;&nbsp;t.start();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5409_23036" name="resp5409_" type="radio" value="23036">        </td>
        <td class="c1 text ">
          <label for="resp5409_23036">
            <span class="anun">b<span class="anumsep">.</span></span> Thread t = new Thread()<br> &nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void start()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{     <br>   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Work.doIt();   <br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  <br>  &nbsp;&nbsp;&nbsp;&nbsp;};   <br> &nbsp;&nbsp;&nbsp;&nbsp;t.start();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5409_23037" name="resp5409_" type="radio" value="23037">        </td>
        <td class="c1 text ">
          <label for="resp5409_23037">
            <span class="anun">c<span class="anumsep">.</span></span> Runnable r = new Runnable() <br>&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void run()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{       <br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Work.doIt();    <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}    <br>&nbsp;&nbsp;&nbsp;&nbsp;};   <br> &nbsp;&nbsp;&nbsp;&nbsp;r.start();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5409_23038" name="resp5409_" type="radio" value="23038">        </td>
        <td class="c1 text ">
          <label for="resp5409_23038">
            <span class="anun">d<span class="anumsep">.</span></span> Thread t = new Thread(new Work());<br>&nbsp;&nbsp;&nbsp;&nbsp;t.start();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5409_23039" name="resp5409_" type="radio" value="23039">        </td>
        <td class="c1 text ">
          <label for="resp5409_23039">
            <span class="anun">e<span class="anumsep">.</span></span> Runnable t = new Runnable() <br>&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void run()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{      <br>   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Work.doIt();    <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  <br>&nbsp;&nbsp;&nbsp;&nbsp; };  <br> &nbsp;&nbsp;&nbsp;&nbsp;t.run();            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> A Thread object created passing a Runnable object as the target, executes the run() method of the Runnable object in a separate thread when started. <br><br>A Runnable object can be given when constructing a Thread object. If no Runnable object is supplied, the Thread object (which implements the Runnable interface) will execute its own run() method. <br><br>A thread is initiated using the start() method of the Thread object. <initiated><br><br>Choice B is incorrect because the method executed by the new thread is run() and not start(). So the run() needs to be overridden instead of start(). <br><br>Choice C is incorrect because the start() method to be invoked is that of the Thread object and not of the Runnable target. <br><br>Choice D is incorrect because of the invalid argument passed to the Thread class constructor. <br><br>Choice E is incorrect because it will simply cause the run() method to be executed as if it were a normal method. <br><a href="http://java.sun.com/docs/books/tutorial/essential/threads/lifecycle.html"><br></a></initiated>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2025%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5410" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                25      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following lines will not compile? Select two choices.<br><br> class MyClass implements Runnable <br>{ <br>
<div style="margin-left: 40px;">public void run(){} <br></div>} <br><br>class Test <br>{<br>
<div style="margin-left: 40px;"> public static void main (String[] args) throws Exception<br>{ <br>
  <div style="margin-left: 40px;">Thread t1 = new Thread(); // 1 <br>Thread t2 = new Thread(new MyClass()); // 2<br> Thread t3 = new Thread(new MyClass(), "Thread3"); // 3<br> Thread t4 = new Thread("Thread4"); //4 <br>Thread t5 = new Thread("Thread5",5); //5 <br>Thread t6 = new Thread("Thread6",new MyClass()); //6 <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5410_23040" name="resp5410_23040" checked="checked" type="checkbox" value="23040">        </td>
        <td class="c1 text ">
          <label for="resp5410_23040">
            <span class="anun">a<span class="anumsep">.</span></span> Line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5410_23041" name="resp5410_23041" type="checkbox" value="23041">        </td>
        <td class="c1 text ">
          <label for="resp5410_23041">
            <span class="anun">b<span class="anumsep">.</span></span> Line 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5410_23042" name="resp5410_23042" type="checkbox" value="23042">        </td>
        <td class="c1 text ">
          <label for="resp5410_23042">
            <span class="anun">c<span class="anumsep">.</span></span> Line 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5410_23043" name="resp5410_23043" checked="checked" type="checkbox" value="23043">        </td>
        <td class="c1 text ">
          <label for="resp5410_23043">
            <span class="anun">d<span class="anumsep">.</span></span> Line 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5410_23044" name="resp5410_23044" checked="checked" type="checkbox" value="23044">        </td>
        <td class="c1 text correct">
          <label for="resp5410_23044">
            <span class="anun">e<span class="anumsep">.</span></span> Line 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5410_23045" name="resp5410_23045" checked="checked" type="checkbox" value="23045">        </td>
        <td class="c1 text correct">
          <label for="resp5410_23045">
            <span class="anun">f<span class="anumsep">.</span></span> Line 6            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices E and F are the correct answers. <br><br>Choices E and F do not compile. <br><br>The valid Thread constructors are: <br>
<ul>
  <li>Thread() </li>
  <li>Thread(Runnable target) </li>
  <li>Thread(Runnable target,String name) </li>
  <li>Thread(String name) </li>
  <li>Thread(ThreadGroup group,Runnable target) </li>
  <li>Thread(ThreadGroup group,Runnable target,String name) </li>
  <li>Thread(ThreadGroup group,String name) </li>
</ul>Choices E and F are thus invalid, whereas all the others are valid constructor calls. <br><br>Reference:<br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2026%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5411" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                26      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following program?<br><br> class Test implements Runnable <br>{ <br>
<div style="margin-left: 40px;">public void run() <br>{<br>
  <div style="margin-left: 40px;"> String str = new String("hello");<br> synchronized (str) <br>{ <br>
    <div style="margin-left: 40px;">try <br>{ <br>
      <div style="margin-left: 40px;">System.out.print(Thread.currentThread().getName());<br> Thread.sleep(5000); <br>System.out.print(Thread.currentThread().getName());<br></div> } <br>catch(InterruptedException e) { }<br><br></div>} <br></div>} <br></div><br>
<div style="margin-left: 40px;">public static void main (String[] args) <br>{ <br>
  <div style="margin-left: 40px;">new Thread(new Test(), "A").start(); <br>new Thread(new Test(), "B").start(); <br></div>} <br></div>}<input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5411_23046" name="resp5411_" checked="checked" type="radio" value="23046">        </td>
        <td class="c1 text correct">
          <label for="resp5411_23046">
            <span class="anun">a<span class="anumsep">.</span></span> Result cannot be predicted            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
           <input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div>        </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5411_23047" name="resp5411_" type="radio" value="23047">        </td>
        <td class="c1 text ">
          <label for="resp5411_23047">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "ABAB" or "BABA"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5411_23048" name="resp5411_" type="radio" value="23048">        </td>
        <td class="c1 text ">
          <label for="resp5411_23048">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "AABB" or "BBAA"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5411_23049" name="resp5411_" type="radio" value="23049">        </td>
        <td class="c1 text ">
          <label for="resp5411_23049">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler Error            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5411_23050" name="resp5411_" type="radio" value="23050">        </td>
        <td class="c1 text ">
          <label for="resp5411_23050">
            <span class="anun">e<span class="anumsep">.</span></span> An exception is thrown            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
      <div class="feedback">
      <input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div>    </div>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>In the given code, the String str is a local variable. A local variable is not shared by threads i.e., each thread has a separate copy of the variable. So when each thread runs, a new String object is created and its lock is obtained by the thread. <br><br>Since the String objects are different, synchronization is not effective here. Here you cannot predict which thread will start first, nor can we predict whether the other thread will run when one thread is sleeping. <br><a href="http://java.sun.com/docs/books/tutorial/essential/threads/multithreaded.html"><br></a><input type="hidden" id="gwProxy"><!--Session data--><input type="hidden" id="jsProxy" onclick="function onclick(event) { jsCall(); }">
<div id="refHTML"></div>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2027%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5412" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                27      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following code? <br><br>class TestThread extends Thread <br>{ <br>
<div style="margin-left: 40px;">public void restart() <br>{<br>
  <div style="margin-left: 40px;"> startMe(); <br></div>} <br>public static void startMe() <br>{ <br>
  <div style="margin-left: 40px;">synchronized(this) <br>{ <br></div>
  <div style="margin-left: 80px;">notifyAll(); <br>System.out.println("Trying to notify"); <br></div>
  <div style="margin-left: 40px;">} <br></div>}<br> public void run() <br>{ <br>
  <div style="margin-left: 40px;">try <br>{ <br></div>
  <div style="margin-left: 80px;">synchronized(this) <br>{ <br></div>
  <div style="margin-left: 120px;">wait(); <br>System.out.println("Notified"); <br></div>
  <div style="margin-left: 80px;">} <br></div>
  <div style="margin-left: 40px;">}<br> catch(InterruptedException e) {} <br></div>} <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">TestThread t1 = new TestThread();<br> t1.start(); <br>t1.restart(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5412_23051" name="resp5412_" type="radio" value="23051">        </td>
        <td class="c1 text ">
          <label for="resp5412_23051">
            <span class="anun">a<span class="anumsep">.</span></span> "Trying to Notify" is printed followed by "Notified"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5412_23052" name="resp5412_" type="radio" value="23052">        </td>
        <td class="c1 text ">
          <label for="resp5412_23052">
            <span class="anun">b<span class="anumsep">.</span></span> "Trying to Notify" alone is printed            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5412_23053" name="resp5412_" type="radio" value="23053">        </td>
        <td class="c1 text ">
          <label for="resp5412_23053">
            <span class="anun">c<span class="anumsep">.</span></span> No output            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5412_23054" name="resp5412_" type="radio" value="23054">        </td>
        <td class="c1 text correct">
          <label for="resp5412_23054">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5412_23055" name="resp5412_" checked="checked" type="radio" value="23055">        </td>
        <td class="c1 text ">
          <label for="resp5412_23055">
            <span class="anun">e<span class="anumsep">.</span></span> Throws an exception at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br><br>The code gives compiler error in the static method startMe(). As you know, static methods do not have a "this" reference and cannot access instance members. So synchronizing on the current object and invoking notifyAll() are not allowed here. <br><br>Since the code does not compile, choices A, B, and C are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2028%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5413" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                28      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements regarding the wait() method are correct? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5413_23056" name="resp5413_23056" checked="checked" type="checkbox" value="23056">        </td>
        <td class="c1 text correct">
          <label for="resp5413_23056">
            <span class="anun">a<span class="anumsep">.</span></span> It is an instance method of Object class.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5413_23057" name="resp5413_23057" type="checkbox" value="23057">        </td>
        <td class="c1 text ">
          <label for="resp5413_23057">
            <span class="anun">b<span class="anumsep">.</span></span> It is a static method of the Object class.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5413_23058" name="resp5413_23058" type="checkbox" value="23058">        </td>
        <td class="c1 text ">
          <label for="resp5413_23058">
            <span class="anun">c<span class="anumsep">.</span></span> It is an instance method of Thread class.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5413_23059" name="resp5413_23059" type="checkbox" value="23059">        </td>
        <td class="c1 text correct">
          <label for="resp5413_23059">
            <span class="anun">d<span class="anumsep">.</span></span> The Thread must have a lock on the object on which the wait() method is to be invoked.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5413_23060" name="resp5413_23060" checked="checked" type="checkbox" value="23060">        </td>
        <td class="c1 text ">
          <label for="resp5413_23060">
            <span class="anun">e<span class="anumsep">.</span></span> An object can have only one Thread in a waiting state at a time.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5413_23061" name="resp5413_23061" checked="checked" type="checkbox" value="23061">        </td>
        <td class="c1 text correct">
          <label for="resp5413_23061">
            <span class="anun">f<span class="anumsep">.</span></span> It must be called in a synchronized code.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, D, and F are the correct answers. <br><br>The wait() method is an instance (non-static) method of the Object class. Thus, choices B and C are incorrect. <br><br>The Thread must have a lock on object on which the wait() method is to be invoked, otherwise IllegalMonitorStateException is thrown at runtime. The wait() and notify() methods must be called in a synchronized code. <br><br>Choice E is incorrect as there can be any number of Threads waiting for an object at a time. <br><br>Check out the API for more about the wait and notify methods:<br> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2029%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5416" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                29      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following are legal? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5416_23072" name="resp5416_23072" type="checkbox" value="23072">        </td>
        <td class="c1 text ">
          <label for="resp5416_23072">
            <span class="anun">a<span class="anumsep">.</span></span> int myArray1[10];            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5416_23073" name="resp5416_23073" checked="checked" type="checkbox" value="23073">        </td>
        <td class="c1 text correct">
          <label for="resp5416_23073">
            <span class="anun">b<span class="anumsep">.</span></span> int myArray2[];            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5416_23074" name="resp5416_23074" checked="checked" type="checkbox" value="23074">        </td>
        <td class="c1 text correct">
          <label for="resp5416_23074">
            <span class="anun">c<span class="anumsep">.</span></span> int myArray3[]   = new int[10];            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5416_23075" name="resp5416_23075" type="checkbox" value="23075">        </td>
        <td class="c1 text ">
          <label for="resp5416_23075">
            <span class="anun">d<span class="anumsep">.</span></span> int myArray4[10] = new int[10];            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5416_23076" name="resp5416_23076" checked="checked" type="checkbox" value="23076">        </td>
        <td class="c1 text correct">
          <label for="resp5416_23076">
            <span class="anun">e<span class="anumsep">.</span></span> int []myArray5   = new int[10];            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5416_23077" name="resp5416_23077" checked="checked" type="checkbox" value="23077">        </td>
        <td class="c1 text ">
          <label for="resp5416_23077">
            <span class="anun">f<span class="anumsep">.</span></span> int myArray6[]   = new int[];            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B, C, and E are the correct answers.<br><br> You can't specify the array dimension in the type declaration (left hand side), so choices A and D are incorrect. In choice F, the array size is missing (right hand side), so choice F is also incorrect. <br><br>Choices B, C, and E are all valid declarations. <a href="http://java.sun.com/docs/books/tutorial/java/data/arraybasics.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2030%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5417" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                30      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following are legal identifiers? Select three choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5417_23078" name="resp5417_23078" type="checkbox" value="23078">        </td>
        <td class="c1 text ">
          <label for="resp5417_23078">
            <span class="anun">a<span class="anumsep">.</span></span> !done            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5417_23079" name="resp5417_23079" checked="checked" type="checkbox" value="23079">        </td>
        <td class="c1 text correct">
          <label for="resp5417_23079">
            <span class="anun">b<span class="anumsep">.</span></span> publicprotected            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5417_23080" name="resp5417_23080" type="checkbox" value="23080">        </td>
        <td class="c1 text ">
          <label for="resp5417_23080">
            <span class="anun">c<span class="anumsep">.</span></span> hello-world            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5417_23081" name="resp5417_23081" checked="checked" type="checkbox" value="23081">        </td>
        <td class="c1 text correct">
          <label for="resp5417_23081">
            <span class="anun">d<span class="anumsep">.</span></span> $34            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5417_23082" name="resp5417_23082" checked="checked" type="checkbox" value="23082">        </td>
        <td class="c1 text correct">
          <label for="resp5417_23082">
            <span class="anun">e<span class="anumsep">.</span></span> _we45$            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B, D, and E are the correct answers. <br><br>A valid identifier must start with a letter, a dollar sign ($), or an underscore (_) and the subsequent characters may be letters, dollar signs, underscores, or digits. Also, the identifier must not be a keyword. Choice B is correct because it starts with a letter and is not a keyword. Choices D and E are correct since starting with a $ or _ is fine. <br><br>Choice A is incorrect because it is illegal to start with a "!" character. <br><br>Choice C is incorrect because "-" character must not be present. <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html-40625"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2031%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5418" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                31      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of compiling and running the following code?<br> <br>class MyOuter <br>{<br>
<div style="margin-left: 40px;"> private class MyInner <br>{<br>
  <div style="margin-left: 40px;"> private float f() <br>{<br></div>
  <div style="margin-left: 80px;"> return 1.2;<br></div>
  <div style="margin-left: 40px;"> }<br></div> }<br><br> MyInner getInner() <br>{<br>
  <div style="margin-left: 40px;"> return new MyInner();<br></div> }<br><br> float getValue() <br>{<br>
  <div style="margin-left: 40px;"> return getInner().f();<br></div> }<br></div> }<br> <br> class Test <br>{<br>
<div style="margin-left: 40px;"> public static void main(String[] args) <br>{<br></div>
<div style="margin-left: 80px;"> MyOuter outer = new MyOuter();<br> System.out.println(outer.getValue());<br></div>
<div style="margin-left: 40px;"><br> }<br></div> }<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5418_23083" name="resp5418_" type="radio" value="23083">        </td>
        <td class="c1 text ">
          <label for="resp5418_23083">
            <span class="anun">a<span class="anumsep">.</span></span> Prints 1.2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5418_23084" name="resp5418_" type="radio" value="23084">        </td>
        <td class="c1 text ">
          <label for="resp5418_23084">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error : Cannot access the functions of a private inner class            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5418_23085" name="resp5418_" checked="checked" type="radio" value="23085">        </td>
        <td class="c1 text ">
          <label for="resp5418_23085">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error : Cannot access the private method of the inner class             <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5418_23086" name="resp5418_" type="radio" value="23086">        </td>
        <td class="c1 text correct">
          <label for="resp5418_23086">
            <span class="anun">d<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer.<br><br> This program does not compile, but the reason has nothing to do with inner classes. The function<br> f() has been declared to return a variable of type float. But the value returned is of type double because double is the default type for floating point numbers in Java. So the compiler complains of possible loss of<br> precision. <br><br>MyInner is a private inner class, so you cannot access it directly from outside code, for example, <br><br>
<div style="margin-left: 40px;">new MyOuter().new MyInner().f();<br></div> <br>will give compiler error. But in the given program we call the inner class method from a method of the outer class, which is allowed.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2032%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5420" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                32      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following import statements are legal? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5420_23091" name="resp5420_23091" type="checkbox" value="23091">        </td>
        <td class="c1 text ">
          <label for="resp5420_23091">
            <span class="anun">a<span class="anumsep">.</span></span> import java.lang;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5420_23092" name="resp5420_23092" type="checkbox" value="23092">        </td>
        <td class="c1 text ">
          <label for="resp5420_23092">
            <span class="anun">b<span class="anumsep">.</span></span> static import java.lang.Math;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5420_23093" name="resp5420_23093" checked="checked" type="checkbox" value="23093">        </td>
        <td class="c1 text correct">
          <label for="resp5420_23093">
            <span class="anun">c<span class="anumsep">.</span></span> import java.lang.Math;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5420_23094" name="resp5420_23094" checked="checked" type="checkbox" value="23094">        </td>
        <td class="c1 text correct">
          <label for="resp5420_23094">
            <span class="anun">d<span class="anumsep">.</span></span> import static java.lang.Math.*;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5420_23095" name="resp5420_23095" type="checkbox" value="23095">        </td>
        <td class="c1 text ">
          <label for="resp5420_23095">
            <span class="anun">e<span class="anumsep">.</span></span> static import java.lang.Math.*;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices C and D are the correct answers.<br><br> The static import construct allows unqualified access to static members without inheriting from the type containing the static members. <br><br>Whereas the normal import declaration imports classes from packages, allowing them to be used without package qualification, the static import declaration imports static members from classes, allowing them to be used without class qualification. <br><br>Choice C is correct because it imports the Math class correctly. <br><br>Choice D is correct because it imports the static members of Math class correctly. <br><br>Choice A is incorrect because you can only import classes or interfaces from a package, and not the package itself. <br><br>Choices B and E are incorrect because the static keyword must follow the import keyword in a static import. <br><br>To know more about static imports, refer to <br><a href="http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.3">http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5.3</a><br><a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html"> http://java.sun.com/j2se/1.5.0/docs/guide/language/static-import.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2033%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5421" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                33      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to compile and run the following class?<br><br> class Base <br>{ <br>
<div style="margin-left: 40px;">Base(int i) <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("Base"); <br></div>} <br></div>} <br><br>class Derived extends Base <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] argv) <br>{<br></div>
<div style="margin-left: 80px;"> Derived d = new Derived(); <br></div>
<div style="margin-left: 40px;">}<br> void Derived() <br>{<br></div>
<div style="margin-left: 80px;"> System.out.println("Derived"); <br></div>
<div style="margin-left: 40px;">} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5421_23096" name="resp5421_" checked="checked" type="radio" value="23096">        </td>
        <td class="c1 text ">
          <label for="resp5421_23096">
            <span class="anun">a<span class="anumsep">.</span></span> Compiles fine and prints "Derived" at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5421_23097" name="resp5421_" type="radio" value="23097">        </td>
        <td class="c1 text correct">
          <label for="resp5421_23097">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5421_23098" name="resp5421_" type="radio" value="23098">        </td>
        <td class="c1 text ">
          <label for="resp5421_23098">
            <span class="anun">c<span class="anumsep">.</span></span> Compiles fine but no output is produced            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5421_23099" name="resp5421_" type="radio" value="23099">        </td>
        <td class="c1 text ">
          <label for="resp5421_23099">
            <span class="anun">d<span class="anumsep">.</span></span> Compiles fine and prints "Base" at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer.<br><br> When an object of the Derived class is constructed in the main method, a super() call is automatically made by the constructor of the class. However, there is no matching constructor (no-args constructor) in the super class. So, the code causes a compiler error. <br><br>The compiler would have provided a default constructor, if no constructors had been written in the base class. However, in this case, the base class already defines a single argument constructor. So, no default constructor is provided. <br><br>Since the code does not compile, all the other choices are incorrect.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2034%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5422" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                34      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing the following code? <br><br>class Vararg2<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px;"> Integer i[]={1,2,3,4}; <br>test(i); <br>test(); <br></div>} <br>public static void test(int... s)<br>{ <br>
  <div style="margin-left: 40px;">for(int i : s) <br>
    <div style="margin-left: 40px;">System.out.printf(" %d \n", i); <br></div></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5422_23100" name="resp5422_" type="radio" value="23100">        </td>
        <td class="c1 text correct">
          <label for="resp5422_23100">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile because test(Integer[]) cannot be applied to test(int?)            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5422_23101" name="resp5422_" checked="checked" type="radio" value="23101">        </td>
        <td class="c1 text ">
          <label for="resp5422_23101">
            <span class="anun">b<span class="anumsep">.</span></span> Does not compile because there test() cannot be applied to test(int?)            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5422_23102" name="resp5422_" type="radio" value="23102">        </td>
        <td class="c1 text ">
          <label for="resp5422_23102">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 1,2,3,4            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5422_23103" name="resp5422_" type="radio" value="23103">        </td>
        <td class="c1 text ">
          <label for="resp5422_23103">
            <span class="anun">d<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The void test(int...) method cannot match the test(i) invocation because i is of type Integer[]. Though Integer can be boxed into int type, Integer[] cannot be boxed to int[]. So the code does not compile. <br><br>Variable arguments (varargs) methods can be invoked with zero arguments also, so choice B is incorrect. <br><br>Since the code does not compile, choice C is incorrect. <br><br>Choice A is correct, thus, choice D is automatically incorrect.<br><br> Refer the following link to learn more on how to use varargs.<br> <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html%20">http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html </a><br><br>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2035%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5423" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                35      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of attempting to compile and run the following code?<br><br> abstract class SuperTest <br>{ <br>
<div style="margin-left: 40px;">static int i=10; <br></div>}<br> class Test extends SuperTest implements Inter <br>{ <br>
<div style="margin-left: 40px;">final static int i; <br>static { i=9; } <br>void f() <br>{<br>
  <div style="margin-left: 40px;"> System.out.println("i is "+i); <br></div>}<br> public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">Inter t = new Test(); <br>t.f(); <br></div>} <br></div>}<br> interface Inter <br>{ <br>
<div style="margin-left: 40px;">int i= 1; <br>void f();<br></div> }<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5423_23104" name="resp5423_" type="radio" value="23104">        </td>
        <td class="c1 text ">
          <label for="resp5423_23104">
            <span class="anun">a<span class="anumsep">.</span></span> Code does not compile because you cannot extend a class and implement an interface at the same time.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5423_23105" name="resp5423_" type="radio" value="23105">        </td>
        <td class="c1 text ">
          <label for="resp5423_23105">
            <span class="anun">b<span class="anumsep">.</span></span> Code does not compile because SuperTest does not contain any abstract methods.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5423_23106" name="resp5423_" type="radio" value="23106">        </td>
        <td class="c1 text ">
          <label for="resp5423_23106">
            <span class="anun">c<span class="anumsep">.</span></span> Code does not compile because a final static variable cannot be initialized in a static block.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5423_23107" name="resp5423_" type="radio" value="23107">        </td>
        <td class="c1 text ">
          <label for="resp5423_23107">
            <span class="anun">d<span class="anumsep">.</span></span> Code compiles and prints 9.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5423_23108" name="resp5423_" type="radio" value="23108">        </td>
        <td class="c1 text ">
          <label for="resp5423_23108">
            <span class="anun">e<span class="anumsep">.</span></span> Code compiles and prints 1.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5423_23109" name="resp5423_" checked="checked" type="radio" value="23109">        </td>
        <td class="c1 text correct">
          <label for="resp5423_23109">
            <span class="anun">f<span class="anumsep">.</span></span> None of the above.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice F is the correct answer. <br><br>The code does not compile, but not because of any of the given reasons. As you know, interface methods are implicitly public. <br><br>When you implement the method in your class, you have to declare the method as public too otherwise you are violating the overriding rule which states that the overriding method cannot have weaker access privileges than the overridden method. Here if you make the f() method public in the Test class, it compiles fine and prints 9. <br><br>Choice A is incorrect because you can extend a class and implement an interface at the same time. <br><br>Choice B is incorrect because an abstract class need not have any abstract methods. <br><br>Choice C is incorrect because a final static variable can be initialized at the time of declaration or in a static block. <a href="http://java.sun.com/docs/books/tutorial/java/interpack/createinterface.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2036%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5424" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                36      </div>
      </div>
  <div class="content">
    <div class="qtext">
  import java.util.*;<br><br> public class Test <br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void f() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Outer"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public class InnerTest <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InnerTest() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Inner constructor"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void f()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Inner f"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String[] args) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test t=new Test(); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test.InnerTest test=t.new InnerTest() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void f() <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.f();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Sub Inner f"); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.f();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5424_23110" name="resp5424_" type="radio" value="23110">        </td>
        <td class="c1 text correct">
          <label for="resp5424_23110">
            <span class="anun">a<span class="anumsep">.</span></span> Code does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5424_23111" name="resp5424_" type="radio" value="23111">        </td>
        <td class="c1 text ">
          <label for="resp5424_23111">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "Inner Constructor", "Outer" and "Sub Inner f"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5424_23112" name="resp5424_" type="radio" value="23112">        </td>
        <td class="c1 text ">
          <label for="resp5424_23112">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "Outer" and " Sub Inner f"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5424_23113" name="resp5424_" type="radio" value="23113">        </td>
        <td class="c1 text ">
          <label for="resp5424_23113">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "Outer", "Inner f" and "Sub Inner f"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5424_23114" name="resp5424_" type="radio" value="23114">        </td>
        <td class="c1 text ">
          <label for="resp5424_23114">
            <span class="anun">e<span class="anumsep">.</span></span> Prints "Inner Constructor", "Outer", "Inner f" and "Sub Inner f"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5424_23115" name="resp5424_" checked="checked" type="radio" value="23115">        </td>
        <td class="c1 text ">
          <label for="resp5424_23115">
            <span class="anun">f<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The given code does not compile because we are attempting to access the method local variable t, from within the local anonymous inner class. A method local class can access local variables in the enclosing method only if the variables are final. So the compiler gives an error. Since the code does not even compile, no output is produced. So all the other choices are incorrect. <br><br>Reference:<br><a href="http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html"> http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2037%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5425" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                37      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the following code for the Demo class, what would be the result of calling the showName() method with an argument of 0 immediately after creating an instance of Demo? <br><br>1. public class Demo <br>2. { <br>3. private String userNames[]; <br>4. public Demo() <br>5. { <br>6. userNames = new String[10]; <br>7. } <br>8. public void showName(int n) <br>9. { <br>10. System.out.println("Name is " + userNames[n]); <br>11. } <br>12. <br>13. public String getName(int n) <br>14. { <br>15. return(userNames[n]); <br>16. } <br>17. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5425_23116" name="resp5425_" checked="checked" type="radio" value="23116">        </td>
        <td class="c1 text correct">
          <label for="resp5425_23116">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "Name is null".            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5425_23117" name="resp5425_" type="radio" value="23117">        </td>
        <td class="c1 text ">
          <label for="resp5425_23117">
            <span class="anun">b<span class="anumsep">.</span></span> A NullPointerException would be thrown.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5425_23118" name="resp5425_" type="radio" value="23118">        </td>
        <td class="c1 text ">
          <label for="resp5425_23118">
            <span class="anun">c<span class="anumsep">.</span></span> An ArrayIndexOutOfBoundsException would be thrown.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5425_23119" name="resp5425_" type="radio" value="23119">        </td>
        <td class="c1 text ">
          <label for="resp5425_23119">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "Name is ".            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>When an array is created using the new operator, all its elements are automatically initialized to the default values for that particular data type. So the elements of the array userNames are initialized to null value, which is the default value for object reference types. So the output is "Name is null", hence choice A is correct while choice D is incorrect. <br><br>No NullPointerException is thrown; hence, choice B is incorrect. <br><br>Since the array index 0 is valid for the first element, no ArrayIndexOutOfBoundsException is thrown. So choice C is also incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2038%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5426" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                38      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and running the following code?<br><br> interface Inter{} <br>class First implements Inter<br>{ <br>
<div style="margin-left: 40px;">public Inter method1() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("super"); <br>return new First(); <br></div>} <br></div>} <br><br>class Second extends First <br>{ <br>
<div style="margin-left: 40px;">public First method1() <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("sub"); <br>return new Second(); <br></div>} <br></div>} <br><br>public class CovariantTest2 <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">First first=new Second(); <br>Inter first1=first.method1(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5426_23120" name="resp5426_" type="radio" value="23120">        </td>
        <td class="c1 text ">
          <label for="resp5426_23120">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5426_23121" name="resp5426_" type="radio" value="23121">        </td>
        <td class="c1 text ">
          <label for="resp5426_23121">
            <span class="anun">b<span class="anumsep">.</span></span> ClassCastException is thrown            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5426_23122" name="resp5426_" type="radio" value="23122">        </td>
        <td class="c1 text ">
          <label for="resp5426_23122">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "super"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5426_23123" name="resp5426_" checked="checked" type="radio" value="23123">        </td>
        <td class="c1 text correct">
          <label for="resp5426_23123">
            <span class="anun">d<span class="anumsep">.</span></span> Prints "sub"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br><br>The code demonstrates the use of covariant return types i.e., the return type of the overriding method is a subtype of the return type of the overridden method. <br><br>Here the super type is an interface, which is perfectly legal. The object of Second class has been assigned to a variable declared to be of type First. This is also allowed since the Second class is a subclass of the First class. Since the code compiles without errors, choice A is incorrect. <br><br>Overriding comes into play here, so even though the declared type of the variable first is First, the method invoked is that of Second class. So the output is "sub". Thus choice C is incorrect while choice D is correct. <br><br>To know more about the covariant return types feature, refer to:<br> <a href="http://java.sun.com/developer/JDCTechTips/2004/tt1201.html">http://java.sun.com/developer/JDCTechTips/2004/tt1201.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2039%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q16289" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                39      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Choose the option that will compile without any errors.</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16289_61929" name="resp16289_" checked="checked" type="radio" value="61929">        </td>
        <td class="c1 text correct">
          <label for="resp16289_61929">
            <span class="anun">a<span class="anumsep">.</span></span> ArrayList &lt;String[]&gt; s=new ArrayList&lt;String[]&gt;();<br>    for(String[] arr : s)<br>    for(String str : arr)<br>    System.out.print(str); for(String[] arr : s) <br>    for(String str : arr)  <br>   System.out.print(str);<br>            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp16289_61930" name="resp16289_" type="radio" value="61930">        </td>
        <td class="c1 text ">
          <label for="resp16289_61930">
            <span class="anun">b<span class="anumsep">.</span></span> ArrayList &lt;String[]&gt; s=new ArrayList&lt;String[]&gt;();<br>    for(String str : s)<br>    System.out.print(str);            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp16289_61931" name="resp16289_" type="radio" value="61931">        </td>
        <td class="c1 text ">
          <label for="resp16289_61931">
            <span class="anun">c<span class="anumsep">.</span></span> ArrayList &lt;String&gt; s=new ArrayList&lt;String&gt;();<br>    for(String[] arr : s)<br>    System.out.print(arr);            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        ANSWER : A <br><br>Explanation: <br>The enhanced for loop is of the form <br><br>for ( VariableModifiersopt Type Identifier: Expression) <br><br>Here, we use two enhanced for loops: one to iterate through the ArrayList and another for each of its String[] elements. <br><br>For each iteration of the outer loop, we get a String[] object which is then iterated over to get its String elements. <br><br>Reference: <br><a target="_blank" href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html">http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2040%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5427" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                40      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to run the following code from the command line using the command - java AssertTest? <br><br>(Assume that the code is compiled with assertions enabled.) <br><br>1. public class AssertTest <br>2. { <br>3. static int i = 10; <br>4. public static void main(String[] args) <br>5. { <br>6. i = i*2; <br>7. try <br>8. { <br>9. assert isValid() : i = i/4; <br>10. } catch(AssertionError ignore){} <br>11. <br>12. System.out.println("i = " +i); <br>13. } <br>14. <br>15. public static boolean isValid() <br>16. { <br>17. i = i * 2; <br>18. return false; <br>19. } <br>20. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5427_23124" name="resp5427_" type="radio" value="23124">        </td>
        <td class="c1 text correct">
          <label for="resp5427_23124">
            <span class="anun">a<span class="anumsep">.</span></span> It will print - i = 20            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5427_23125" name="resp5427_" checked="checked" type="radio" value="23125">        </td>
        <td class="c1 text ">
          <label for="resp5427_23125">
            <span class="anun">b<span class="anumsep">.</span></span> It will print - i = 10            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5427_23126" name="resp5427_" type="radio" value="23126">        </td>
        <td class="c1 text ">
          <label for="resp5427_23126">
            <span class="anun">c<span class="anumsep">.</span></span> It will print - i = 40            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5427_23127" name="resp5427_" type="radio" value="23127">        </td>
        <td class="c1 text ">
          <label for="resp5427_23127">
            <span class="anun">d<span class="anumsep">.</span></span> It will print - i = 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5427_23128" name="resp5427_" type="radio" value="23128">        </td>
        <td class="c1 text ">
          <label for="resp5427_23128">
            <span class="anun">e<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer.<br><br> The code will print - i = 20. It is important to understand when the assert statement gets executed. Note that this code is run without enabling the assertions. The command - java AssertTest does not use any command line switch to enable the assertions in the AssertTest class. However, as stated in the question, the code is compiled with assertions enabled. Let's look at the execution of the code. <br><br>At line 3, a static int i is assigned the value 10. When the main method starts executing, at line 6 the value of i becomes 20. Next, since assertions are NOT enabled while running the program, the statement at line 9 is not executed. Hence, the isValid() method is not invoked in this execution. <br><br>It is very important to understand that assert statements get executed conditionally, depending upon whether the assertions are enabled or disabled at runtime. Hence, assert statement should not have any side effects and should not alter the state of the object (unlike this code). <br><br>The next statement, the print statement at line 12 prints the value of i, which is 20. Since the value of i has not been altered after line 6, the code will print - i = 20. <br><br>Want to know more? You can read more about assertions, their usage, and how to enable or disable them at -<a href="http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html">http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2041%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5428" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                41      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which methods can legally be inserted after the comment //XX? Select four choices. <br><br>class Parent<br>{ <br>
<div style="margin-left: 40px;"> public void amethod(int i) throws IOException, RuntimeException <br> {<br>
  <div style="margin-left: 40px;"> ? <br></div> } <br></div>} <br>public class Child extends Parent <br>{<br>
<div style="margin-left: 40px;"> //XX <br></div>}<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5428_23129" name="resp5428_23129" checked="checked" type="checkbox" value="23129">        </td>
        <td class="c1 text correct">
          <label for="resp5428_23129">
            <span class="anun">a<span class="anumsep">.</span></span> public void amethod(int i) throws FileNotFoundException{}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
          
		        </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5428_23130" name="resp5428_23130" checked="checked" type="checkbox" value="23130">        </td>
        <td class="c1 text correct">
          <label for="resp5428_23130">
            <span class="anun">b<span class="anumsep">.</span></span> public void amethod(int i) throws IOException, RuntimeException{}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5428_23131" name="resp5428_23131" checked="checked" type="checkbox" value="23131">        </td>
        <td class="c1 text correct">
          <label for="resp5428_23131">
            <span class="anun">c<span class="anumsep">.</span></span> public void amethod(int i) throws RuntimeException{}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5428_23132" name="resp5428_23132" type="checkbox" value="23132">        </td>
        <td class="c1 text ">
          <label for="resp5428_23132">
            <span class="anun">d<span class="anumsep">.</span></span> public void amethod(int i) throws Exception{}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5428_23133" name="resp5428_23133" checked="checked" type="checkbox" value="23133">        </td>
        <td class="c1 text correct">
          <label for="resp5428_23133">
            <span class="anun">e<span class="anumsep">.</span></span> public void amethod(int i){}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5428_23134" name="resp5428_23134" type="checkbox" value="23134">        </td>
        <td class="c1 text ">
          <label for="resp5428_23134">
            <span class="anun">f<span class="anumsep">.</span></span> public void amethod(int i) throws Throwable{}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, B, C, and E are the correct answers. <br><br>The overriding method is not allowed to throw new or wider checked exceptions than what is thrown by the overridden method. However, there are no restrictions on throwing unchecked exceptions. <br><br>Choice A compiles because FileNotFoundException thrown by the overriding method is a subclass of IOException thrown by the overridden method. <br><br>Choice B is legal because IOException can be thrown in the superclass method and there are no restrictions on RuntimeException since it is unchecked. <br><br>Choice C is correct because of the same reason. <br><br>Choices D and F are incorrect since Exception and Throwable are wider than IOException and hence cannot be thrown. <br><br>Reference:<br> <a href="http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html">http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2042%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5429" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                42      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following will be part of the output if the given code fragment is executed? Select three choices.<br><br>for(int i = 0; i &lt; 5; i++) <br>{ <br>
<div style="margin-left: 40px;">for(int j = 0; j &lt; 5; j++) <br>{ <br>
  <div style="margin-left: 40px;">if (i != j) <br>{ <br>
    <div style="margin-left: 40px;">continue; <br></div>} <br>System.out.println("i = " + i + " j = " + j); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5429_23135" name="resp5429_23135" checked="checked" type="checkbox" value="23135">        </td>
        <td class="c1 text correct">
          <label for="resp5429_23135">
            <span class="anun">a<span class="anumsep">.</span></span> i = 0 j = 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5429_23136" name="resp5429_23136" type="checkbox" value="23136">        </td>
        <td class="c1 text ">
          <label for="resp5429_23136">
            <span class="anun">b<span class="anumsep">.</span></span> i = 1 j = 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5429_23137" name="resp5429_23137" checked="checked" type="checkbox" value="23137">        </td>
        <td class="c1 text correct">
          <label for="resp5429_23137">
            <span class="anun">c<span class="anumsep">.</span></span> i = 1 j = 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5429_23138" name="resp5429_23138" checked="checked" type="checkbox" value="23138">        </td>
        <td class="c1 text correct">
          <label for="resp5429_23138">
            <span class="anun">d<span class="anumsep">.</span></span> i = 2 j = 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5429_23139" name="resp5429_23139" type="checkbox" value="23139">        </td>
        <td class="c1 text ">
          <label for="resp5429_23139">
            <span class="anun">e<span class="anumsep">.</span></span> i = 5 j = 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A, C, and D are the correct answers.<br><br> Since the inner loop executes a continue statement whenever i and j are not equal and the value is printed after the continue statement, only choices A, C, and D are correct. <br><br>Choice E will never occur as it is out of bounds, choice B will not occur because the continue statement will skip the execution.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2043%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5430" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                43      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Suppose a NullPointerException is thrown by the test() method. Which message is displayed? Select three choices. <br><br>void Method() <br>{ <br>
<div style="margin-left: 40px;">try <br>{ <br>
  <div style="margin-left: 40px;">test(); <br>System.out.println("Message1"); <br></div>} <br>catch (RuntimeException e) <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("Message2"); <br></div>} <br>finally <br>{ <br>
  <div style="margin-left: 40px;">System.out.println("Message3"); <br></div>} <br>System.out.println("Message4"); <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5430_23140" name="resp5430_23140" type="checkbox" value="23140">        </td>
        <td class="c1 text ">
          <label for="resp5430_23140">
            <span class="anun">a<span class="anumsep">.</span></span> Message1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5430_23141" name="resp5430_23141" checked="checked" type="checkbox" value="23141">        </td>
        <td class="c1 text correct">
          <label for="resp5430_23141">
            <span class="anun">b<span class="anumsep">.</span></span> Message2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5430_23142" name="resp5430_23142" checked="checked" type="checkbox" value="23142">        </td>
        <td class="c1 text correct">
          <label for="resp5430_23142">
            <span class="anun">c<span class="anumsep">.</span></span> Message3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5430_23143" name="resp5430_23143" checked="checked" type="checkbox" value="23143">        </td>
        <td class="c1 text correct">
          <label for="resp5430_23143">
            <span class="anun">d<span class="anumsep">.</span></span> Message4            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices B, C and D are the correct answers.<br><br> When an exception occurs in the try block, the statements below it, within the try block, are not executed. So "Message1" is not printed, thus choice A is incorrect. <br><br>RuntimeException is the superclass of NullPointerException, so the control moves to that catch block when the exception is thrown. Here the output is "Message2". After the catch block completes, the control moves to the finally block, so "Message3" is also printed. <br><br>Once the finally block is over, the remaining code is also executed printing "Message4", which makes choice D also correct. <br><br>Reference:<br> <a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html">http://java.sun.com/docs/books/tutorial/essential/exceptions/handling.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2044%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5431" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                44      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following is the most appropriate code snippet that can be inserted at line 18 in the following code? <br>(Assume that the code is compiled and run with assertions enabled.) <br><br>1. import java.util.*; <br>2. <br>3. public class AssertTest <br>4. { <br>5. private HashMap cctld; <br>6. <br>7. public AssertTest() <br>8. { <br>9. cctld = new HashMap(); <br>10. cctld.put("in", "India"); <br>11. cctld.put("uk", "United Kingdom"); <br>12. cctld.put("au", "Australia"); <br>13. // more code... <br>14. } <br>15. // other methods .... <br>16. public String getCountry(String countryCode) <br>17. { <br>18. // What should be inserted here? <br>19. String country = (String)cctld.get(countryCode); <br>20. return country; <br>21. } <br>22. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5431_23144" name="resp5431_" type="radio" value="23144">        </td>
        <td class="c1 text ">
          <label for="resp5431_23144">
            <span class="anun">a<span class="anumsep">.</span></span> assert countryCode != null;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5431_23145" name="resp5431_" checked="checked" type="radio" value="23145">        </td>
        <td class="c1 text ">
          <label for="resp5431_23145">
            <span class="anun">b<span class="anumsep">.</span></span> assert countryCode != null : "Country code can not be null" ;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5431_23146" name="resp5431_" type="radio" value="23146">        </td>
        <td class="c1 text correct">
          <label for="resp5431_23146">
            <span class="anun">c<span class="anumsep">.</span></span> assert cctld != null : "No country code data is available";            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5431_23147" name="resp5431_" type="radio" value="23147">        </td>
        <td class="c1 text ">
          <label for="resp5431_23147">
            <span class="anun">d<span class="anumsep">.</span></span> assert cctld : "No country code data is available";            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5431_23148" name="resp5431_" type="radio" value="23148">        </td>
        <td class="c1 text ">
          <label for="resp5431_23148">
            <span class="anun">e<span class="anumsep">.</span></span> assert cctld.size() != 0 : "No country code data is available";            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer.<br><br> Among the given choices, the code snippet - <br><br>assert cctld != null : "No country code data is available"; <br><br>gives the most appropriate code snippet that can be inserted at line 18. This may sound strange, but assertions should be used to check for conditions that should never happen. <br><br>In this code, the constructor of the class creates a HashMap that contains country codes and their respective countries. Whenever an object of this class is created, one may assume that the HashMap object cctld will be created. But, there is a possibility that other methods may alter the HashMap, and could even make it null. Hence, it is appropriate to check that cctld is not null. <br><br>Let us now discuss why other choices are not really appropriate in this situation. <br><br>Java insists that assertions should not be used to check validity of arguments of a public method; this should be done using exceptions. This is justified for two reasons - <br>
<ol>
  <li>Exceptions can be explicitly mentioned in the throws cause of the method and checked exceptions must be caught while invoking the method.</li>
  <li>Assertions can be disabled while running the code.<br></li>
</ol>Hence, choices A and B are incorrect. Besides, passing null to the get method of HashMap will not result in an error or exception. <br><br>Choice D will not even compile, the first expression of an assert statement must be a boolean. Hence choice D is incorrect. <br><br>Choice E apparently looks quite appropriate, but when assertions are disabled, a HashMap with no entries will not cause any exception or error if its get() method is called with any key. Checking if the size of the HashMap is zero, and throwing an exception in that case, must be part of the program logic itself. <br><br>That leaves us with choice C. Assume that if any other method makes cctld null, the call cctld.get(countryCode);at line 19 will result in a NullPointerException. The code snippet in choice C will ensure that if this assert statement evaluates to true, the call at line 19 will not result in an error or exception. Hence, among the given choices, C is the most appropriate choice. <br><br>In real life code, very often such data comes from the database; and complex data structures are created conditionally. In such cases, usage of assertions as shown above provides the necessary sanity checks. <br><br>Want to know more? You can read more about assertions, their usage, how and when to use them appropriately at - <br><a href="http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html">http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2045%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5432" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                45      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will happen when you attempt to run the following code from the command line using command - java AssertDemo? <br>(Assume that the code is compiled with assertions enabled.) <br><br>1. public class AssertDemo <br>2. { <br>3. public static void main(String args[]) <br>4. { <br>5. boolean assertEnabled = false; <br>6. <br>7. assert assertEnabled = true; <br>8. <br>9. System.out.println("Assertions are " + <br>10. (assertEnabled ? "enabled" : "disabled")); <br>11. } <br>12. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5432_23149" name="resp5432_" type="radio" value="23149">        </td>
        <td class="c1 text ">
          <label for="resp5432_23149">
            <span class="anun">a<span class="anumsep">.</span></span> It will throw an AsertionError.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5432_23150" name="resp5432_" checked="checked" type="radio" value="23150">        </td>
        <td class="c1 text ">
          <label for="resp5432_23150">
            <span class="anun">b<span class="anumsep">.</span></span> The code will not compile, compilation error at line 7.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5432_23151" name="resp5432_" type="radio" value="23151">        </td>
        <td class="c1 text correct">
          <label for="resp5432_23151">
            <span class="anun">c<span class="anumsep">.</span></span> It will print - Assertions are disabled.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5432_23152" name="resp5432_" type="radio" value="23152">        </td>
        <td class="c1 text ">
          <label for="resp5432_23152">
            <span class="anun">d<span class="anumsep">.</span></span> It will print - Assertions are enabled.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5432_23153" name="resp5432_" type="radio" value="23153">        </td>
        <td class="c1 text ">
          <label for="resp5432_23153">
            <span class="anun">e<span class="anumsep">.</span></span> None of these.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The code will compile and run without any error and it will print - Assertions are disabled. Note that this code is run without enabling the assertions. The command - java AssertDemo does not use any command line switch to enable the assertions in the class AssertDemo. However, as stated in the question, the code is compiled with assertions enabled. <br><br>There is nothing wrong with line 7, and it will compile without any error. The expression assertEnabled = true; is indeed a boolean expression that yields true. The single "=" operator performs an assignment rather than a comparison. In this particular case, this side effect is desired. Otherwise, an assert statement should have no side effects, and should not alter the state of the object. <br><br>The statement at line 5 assigns false to a variable assertEnabled. Since the program is run without enabling the assertions, the statement at line 7 is not executed, and hence the value of assertEnabled remains false. So print statement at line 9-10 prints - Assertions are disabled. <br><br>If the same code is run from command line with command - java -ea AssertDemo, it will enable the assertions and will print - Assertions are enabled. But with the given statement, only choice C is correct. <br><br>Want to know more? You can read more about assertions, their usage, and how to enable or disable them at -<br> <a href="http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html">http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2046%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5436" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                46      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following access are illegal for the getMe() method in class B? <br><br>class A<br>{ <br>
<div style="margin-left: 40px;">void getMe(){} <br></div>} <br>class B extends A<br>{ <br>
<div style="margin-left: 40px;">void getMe(){} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5436_23170" name="resp5436_" type="radio" value="23170">        </td>
        <td class="c1 text ">
          <label for="resp5436_23170">
            <span class="anun">a<span class="anumsep">.</span></span> public            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5436_23171" name="resp5436_" type="radio" value="23171">        </td>
        <td class="c1 text ">
          <label for="resp5436_23171">
            <span class="anun">b<span class="anumsep">.</span></span> protected            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5436_23172" name="resp5436_" checked="checked" type="radio" value="23172">        </td>
        <td class="c1 text correct">
          <label for="resp5436_23172">
            <span class="anun">c<span class="anumsep">.</span></span> private            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5436_23173" name="resp5436_" type="radio" value="23173">        </td>
        <td class="c1 text ">
          <label for="resp5436_23173">
            <span class="anun">d<span class="anumsep">.</span></span> default            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices C is the correct answer. <br><br>When you override a method, the overriding method must not have a less restricted access than the overridden method. Thus, a method with no access modifier (default access) may be overridden to be of default, protected or public access. <br><br>Since private is more restricted than default access, it is not allowed, while all the others are allowed. So choice C is correct and the others are incorrect.<a href="http://java.sun.com/docs/books/tutorial/java/javaOO/override.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2047%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5437" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                47      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the output when you compile and execute the following program? <br><br>public class Base <br>{ <br>
<div style="margin-left: 40px;">private void test() <br>{<br>
  <div style="margin-left: 40px;"> System.out.println(6 &amp;&amp; 3); <br></div>} <br>static public void main(String[] a) <br>{ <br>
  <div style="margin-left: 40px;">new Base().test(); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5437_23174" name="resp5437_" type="radio" value="23174">        </td>
        <td class="c1 text ">
          <label for="resp5437_23174">
            <span class="anun">a<span class="anumsep">.</span></span> Prints true            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5437_23175" name="resp5437_" type="radio" value="23175">        </td>
        <td class="c1 text ">
          <label for="resp5437_23175">
            <span class="anun">b<span class="anumsep">.</span></span> Prints false            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5437_23176" name="resp5437_" type="radio" value="23176">        </td>
        <td class="c1 text ">
          <label for="resp5437_23176">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 9            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5437_23177" name="resp5437_" type="radio" value="23177">        </td>
        <td class="c1 text ">
          <label for="resp5437_23177">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5437_23178" name="resp5437_" type="radio" value="23178">        </td>
        <td class="c1 text ">
          <label for="resp5437_23178">
            <span class="anun">e<span class="anumsep">.</span></span> Compiler error : Incorrect declaration of main method            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5437_23179" name="resp5437_" checked="checked" type="radio" value="23179">        </td>
        <td class="c1 text correct">
          <label for="resp5437_23179">
            <span class="anun">f<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice F is the correct answer. <br><br>The code does not compile because the &amp;&amp; operator works only with boolean operands. If both operands are true, the &amp;&amp; operator returns true and false in all the other cases. In this case, integer operands are passed to the &amp;&amp; operator, so the code does not compile. Since the code does not compile, choices A to D are incorrect. <br><br>Choice E is incorrect because there is nothing wrong with the declaration of the main method. The modifiers public and static can appear in any order. Also, the main method takes a String[] as the argument. <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/relational.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2048%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5439" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                48      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the class CommandLineTest <br><br>class CommandLineTest<br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">System.out.print(____); <br></div>} <br></div>} <br><br>Which of the following expressions can be passed to the print method to output 2, if you execute the class using the following command <br><br>java -cp . CommandLineTest 3 "+" 2 "=" 5</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5439_23184" name="resp5439_" type="radio" value="23184">        </td>
        <td class="c1 text ">
          <label for="resp5439_23184">
            <span class="anun">a<span class="anumsep">.</span></span> args[0]            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5439_23185" name="resp5439_" type="radio" value="23185">        </td>
        <td class="c1 text ">
          <label for="resp5439_23185">
            <span class="anun">b<span class="anumsep">.</span></span> args[1]            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5439_23186" name="resp5439_" checked="checked" type="radio" value="23186">        </td>
        <td class="c1 text correct">
          <label for="resp5439_23186">
            <span class="anun">c<span class="anumsep">.</span></span> args[2]            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5439_23187" name="resp5439_" type="radio" value="23187">        </td>
        <td class="c1 text ">
          <label for="resp5439_23187">
            <span class="anun">d<span class="anumsep">.</span></span> args[3]            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5439_23188" name="resp5439_" type="radio" value="23188">        </td>
        <td class="c1 text ">
          <label for="resp5439_23188">
            <span class="anun">e<span class="anumsep">.</span></span> None of these            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>The command-line arguments passed to the java command are read into the args array. <br><br>The class name is not included in the command-line arguments. So args[0] returns 3, args1 returns "+", args2 returns 2 and so on. So C is correct and the other choices are automatically incorrect. <br><br>Reference:<br> <a href="http://java.sun.com/docs/books/tutorial/essential/attributes/cmdLineArgs.html">http://java.sun.com/docs/books/tutorial/essential/attributes/cmdLineArgs.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2049%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5441" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                49      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What is the result of compiling and executing this code? <br><br>class PassTest<br>{ <br>
<div style="margin-left: 40px;">int i=3; <br></div>} <br>public class Test<br>{ <br>
<div style="margin-left: 40px;">public static void xx(PassTest p)<br>{ <br>
  <div style="margin-left: 40px;">p.i=10; <br></div>} <br>public static void yy(PassTest p)<br>{ <br>
  <div style="margin-left: 40px;">p=new PassTest(); <br></div>} <br>public static void main(String[] args)<br>{<br>
  <div style="margin-left: 40px;"> PassTest passTest=new PassTest(); <br>xx(passTest);<br> System.out.println(passTest.i);<br> yy(passTest);<br> System.out.println(passTest.i); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5441_23195" name="resp5441_" type="radio" value="23195">        </td>
        <td class="c1 text ">
          <label for="resp5441_23195">
            <span class="anun">a<span class="anumsep">.</span></span> Does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5441_23196" name="resp5441_" type="radio" value="23196">        </td>
        <td class="c1 text ">
          <label for="resp5441_23196">
            <span class="anun">b<span class="anumsep">.</span></span> Prints 3 10            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5441_23197" name="resp5441_" type="radio" value="23197">        </td>
        <td class="c1 text ">
          <label for="resp5441_23197">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 3 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5441_23198" name="resp5441_" checked="checked" type="radio" value="23198">        </td>
        <td class="c1 text correct">
          <label for="resp5441_23198">
            <span class="anun">d<span class="anumsep">.</span></span> Prints 10 10            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5441_23199" name="resp5441_" type="radio" value="23199">        </td>
        <td class="c1 text ">
          <label for="resp5441_23199">
            <span class="anun">e<span class="anumsep">.</span></span> Prints 10 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br><br>When a method which takes an object argument is invoked, the method obtains a copy of the object reference from the calling method. Both the original reference variable and the copy refer to the same object in memory. So, altering the object within the method affects the original object itself. <br><br>In the xx() method, setting i=10 using p, alters the object which is referenced by both p and passTest variables. So 10 is output when the value of i is printed. However, in the yy() method, the argument variable p is made to refer to a new PassTest object. <br><br>This does not affect the reference variable passTest in the original method. So passTest still refers to the object which has the value of i set to 10. So the output is 10 again. <br><br>Since choice D is correct, all the other choices are automatically incorrect.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2050%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5442" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                50      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What results from running the code below? <br><br>int a = -5;<br>int b = -2;<br> System.out.println(a % b);</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5442_23200" name="resp5442_" type="radio" value="23200">        </td>
        <td class="c1 text ">
          <label for="resp5442_23200">
            <span class="anun">a<span class="anumsep">.</span></span> 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5442_23201" name="resp5442_" type="radio" value="23201">        </td>
        <td class="c1 text ">
          <label for="resp5442_23201">
            <span class="anun">b<span class="anumsep">.</span></span> 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5442_23202" name="resp5442_" checked="checked" type="radio" value="23202">        </td>
        <td class="c1 text correct">
          <label for="resp5442_23202">
            <span class="anun">c<span class="anumsep">.</span></span> -1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5442_23203" name="resp5442_" type="radio" value="23203">        </td>
        <td class="c1 text ">
          <label for="resp5442_23203">
            <span class="anun">d<span class="anumsep">.</span></span> A compiler error saying "%" operator is not valid for negative numbers.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>To calculate a % b (a modulus b), the simplest way is to drop any negative signs from both the operands and compute the result. <br><br>Now, if the left-hand side operand is negative, negate the result, the sign of the right-hand side operand doesn't matter. In our case (-5 % -2) is equal to -(5 % 2) = -(1) = -1, hence choice C is correct. <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arithmetic.html"><br></a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2051%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5443" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                51      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the output when you compile and execute the following program? <br><br>class Test <br>{ <br> public static void main(String[] args) <br>{ <br> 1. Boolean b1 = true; <br>2. boolean b2 = false; <br>3. System.out.print(!b1 ^ b2); <br>4. System.out.print(b1 &amp; (b2 = true)); <br>5. System.out.println(b2 &amp;&amp; (b1 | b2)); <br> } <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5443_23204" name="resp5443_" type="radio" value="23204">        </td>
        <td class="c1 text ">
          <label for="resp5443_23204">
            <span class="anun">a<span class="anumsep">.</span></span> truetruetrue            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5443_23205" name="resp5443_" checked="checked" type="radio" value="23205">        </td>
        <td class="c1 text correct">
          <label for="resp5443_23205">
            <span class="anun">b<span class="anumsep">.</span></span> falsetruetrue            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5443_23206" name="resp5443_" type="radio" value="23206">        </td>
        <td class="c1 text ">
          <label for="resp5443_23206">
            <span class="anun">c<span class="anumsep">.</span></span> falsefalsefalse            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5443_23207" name="resp5443_" type="radio" value="23207">        </td>
        <td class="c1 text ">
          <label for="resp5443_23207">
            <span class="anun">d<span class="anumsep">.</span></span> truetruefalse            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5443_23208" name="resp5443_" type="radio" value="23208">        </td>
        <td class="c1 text ">
          <label for="resp5443_23208">
            <span class="anun">e<span class="anumsep">.</span></span> truefalsetrue            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5443_23209" name="resp5443_" type="radio" value="23209">        </td>
        <td class="c1 text ">
          <label for="resp5443_23209">
            <span class="anun">f<span class="anumsep">.</span></span> Code does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>The ^ (xor) operator returns true if exactly one operand is true. <br><br>The ! operator inverts the operand's boolean value. In line 3, the expression (!b1 ^ b2) yields false because both operands evaluate to false. <br><br>In line 4, b2 is assigned a true value, so b1 &amp; b2 is true. Since both b1 and b2 are true, line 5 also results in an output of true.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2052%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5444" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                52      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following statements are true? Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5444_23210" name="resp5444_23210" type="checkbox" value="23210">        </td>
        <td class="c1 text correct">
          <label for="resp5444_23210">
            <span class="anun">a<span class="anumsep">.</span></span> Garbage collection is performed by a low priority daemon thread.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5444_23211" name="resp5444_23211" type="checkbox" value="23211">        </td>
        <td class="c1 text ">
          <label for="resp5444_23211">
            <span class="anun">b<span class="anumsep">.</span></span> Garbage collection always uses a mark and sweep algorithm            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5444_23212" name="resp5444_23212" type="checkbox" value="23212">        </td>
        <td class="c1 text ">
          <label for="resp5444_23212">
            <span class="anun">c<span class="anumsep">.</span></span> The finalize() method is invoked for objects in the order in which they were created            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5444_23213" name="resp5444_23213" checked="checked" type="checkbox" value="23213">        </td>
        <td class="c1 text correct">
          <label for="resp5444_23213">
            <span class="anun">d<span class="anumsep">.</span></span> The finalize() method is typically used to free up resources other than memory            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5444_23214" name="resp5444_23214" checked="checked" type="checkbox" value="23214">        </td>
        <td class="c1 text ">
          <label for="resp5444_23214">
            <span class="anun">e<span class="anumsep">.</span></span> Objects that are created and accessed locally within a method, are eligible for garbage collection when the method returns.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and D are the correct answers.<br><br> The finalize() method is typically used to free up resources like files, network connections etc. Freeing the memory is the job of the garbage collector only. Garbage collection is performed by a low priority daemon thread, which dies when no more user threads are running. So choices A and D are correct. <br><br>The algorithm used for garbage collection is dependent on the vendor, so choice B is incorrect. The order in which the finalize() methods are invoked cannot be predicted, it is not dependent on the order in which the objects were created. So choice C is also incorrect. <br><br>Objects that are created and accessed locally within a method are eligible for garbage collection, after the method terminates, unless references to these objects are exported out of the method.So choice E is also incorrect. <br><br>Want to know more? You can read more about garbage collection at -<br> <a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html">http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html</a><br> <a href="http://www.developer.com/tech/article.php/628881">http://www.developer.com/tech/article.php/628881</a><br> <br>Also, the API documentation of the Object class contains the necessary information about the finalize() method - <a href="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html">http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html</a>      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2053%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5446" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                53      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Assume that MyClass is a class which defines two methods f() and g(). How many objects would be eligible for garbage collection by the time the method g() is invoked? <br><br>MyClass c1 = new MyClass(); <br>MyClass c2 = new MyClass();<br> f(c1);<br> c1=null; <br>c2=c1; <br>g();</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5446_23219" name="resp5446_" type="radio" value="23219">        </td>
        <td class="c1 text ">
          <label for="resp5446_23219">
            <span class="anun">a<span class="anumsep">.</span></span> 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5446_23220" name="resp5446_" type="radio" value="23220">        </td>
        <td class="c1 text ">
          <label for="resp5446_23220">
            <span class="anun">b<span class="anumsep">.</span></span> 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5446_23221" name="resp5446_" type="radio" value="23221">        </td>
        <td class="c1 text ">
          <label for="resp5446_23221">
            <span class="anun">c<span class="anumsep">.</span></span> 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5446_23222" name="resp5446_" checked="checked" type="radio" value="23222">        </td>
        <td class="c1 text correct">
          <label for="resp5446_23222">
            <span class="anun">d<span class="anumsep">.</span></span> The given information is insufficient            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice D is the correct answer. <br><br>The reference to c1 has been passed to a method and the method body is not shown here. We do not know if the function is passing this object's reference to other live threads. <br><br>So we cannot be sure that the object referred to by c1 is eligible for garbage collection or not. Thus, the information is insufficient to predict the result.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2054%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5447" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                54      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of compiling and running the following code? <br><br>class SuperTest <br>{ <br>
<div style="margin-left: 40px;">SuperTest() throws Exception { }<br>int f() <br>{<br>
  <div style="margin-left: 40px;"> return 0;<br></div> }<br></div> }<br> <br>public class Test extends SuperTest <br>{ <br>
<div style="margin-left: 40px;">int i; <br>int f() <br>{ <br>
  <div style="margin-left: 40px;">return i; <br></div>} <br>Test(int i) <br>{ <br>
  <div style="margin-left: 40px;">this.i=i; <br></div>} <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">SuperTest t=new Test(5);<br> System.out.println(t.f()); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5447_23223" name="resp5447_" checked="checked" type="radio" value="23223">        </td>
        <td class="c1 text correct">
          <label for="resp5447_23223">
            <span class="anun">a<span class="anumsep">.</span></span> Code does not compile            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5447_23224" name="resp5447_" type="radio" value="23224">        </td>
        <td class="c1 text ">
          <label for="resp5447_23224">
            <span class="anun">b<span class="anumsep">.</span></span> Prints 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5447_23225" name="resp5447_" type="radio" value="23225">        </td>
        <td class="c1 text ">
          <label for="resp5447_23225">
            <span class="anun">c<span class="anumsep">.</span></span> Prints 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5447_23226" name="resp5447_" type="radio" value="23226">        </td>
        <td class="c1 text ">
          <label for="resp5447_23226">
            <span class="anun">d<span class="anumsep">.</span></span> Exception is thrown at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice A is the correct answer. <br><br>The code does not compile because the superclass constructor throws an Exception which is not handled in the subclass constructor. So the compiler complains. <br><br>The subclass constructor makes an implicit call to the superclass parameterless constructor. So it has to catch the Exception or declare it in a throws clause.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2055%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5448" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                55      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following code? <br><br>class SuperBase{} <br>class Base extends SuperBase{} <br>class Derived extends Base{} <br>public class Test <br>{ <br>
<div style="margin-left: 40px;">public static void main(String[] args)<br>{ <br>
  <div style="margin-left: 40px;">SuperBase[] s1 = new Base[2]; //1<br> SuperBase[] s2 = new Derived[1]{new Derived()}; //2 <br>Base[] b1 = new Derived[0]; //3 <br>Derived[] d1 = (Derived[])s2; //4 <br>Base[] b3 = d1; //5 <br>s1 = b1; //6 <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23227" name="resp5448_" type="radio" value="23227">        </td>
        <td class="c1 text ">
          <label for="resp5448_23227">
            <span class="anun">a<span class="anumsep">.</span></span> Compiler error at line 1            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23228" name="resp5448_" type="radio" value="23228">        </td>
        <td class="c1 text correct">
          <label for="resp5448_23228">
            <span class="anun">b<span class="anumsep">.</span></span> Compiler error at line 2            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23229" name="resp5448_" type="radio" value="23229">        </td>
        <td class="c1 text ">
          <label for="resp5448_23229">
            <span class="anun">c<span class="anumsep">.</span></span> Compiler error at line 3            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23230" name="resp5448_" type="radio" value="23230">        </td>
        <td class="c1 text ">
          <label for="resp5448_23230">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler error at line 4            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23231" name="resp5448_" type="radio" value="23231">        </td>
        <td class="c1 text ">
          <label for="resp5448_23231">
            <span class="anun">e<span class="anumsep">.</span></span> Compiler error at line 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23232" name="resp5448_" type="radio" value="23232">        </td>
        <td class="c1 text ">
          <label for="resp5448_23232">
            <span class="anun">f<span class="anumsep">.</span></span> Compiler error at line 6            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23233" name="resp5448_" checked="checked" type="radio" value="23233">        </td>
        <td class="c1 text ">
          <label for="resp5448_23233">
            <span class="anun">g<span class="anumsep">.</span></span> Compiles and runs without errors            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5448_23234" name="resp5448_" type="radio" value="23234">        </td>
        <td class="c1 text ">
          <label for="resp5448_23234">
            <span class="anun">h<span class="anumsep">.</span></span> Throws ClassCastException at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>This is a tricky question, here the problem is with the array creation syntax. <br><br>When we use this syntax to create arrays, we should not specify the size, the size is evaluated from the number of elements between the curly braces. Here the declaration should be changed to new Derived[]{new Derived()}. <br><br>Other than this there are no errors in this program. A derived class array can be assigned to a base class array. So all the other assignments are valid. It is legal to make an array of size 0 also.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2056%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5449" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                56      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of an attempt to compile and run the following code? <br><br>class Test <br>{ <br>
<div style="margin-left: 40px;">static Object test="hello";<br> void f(Object x)<br> {<br>
  <div style="margin-left: 40px;">System.out.print("Object");<br></div>} <br>void f(String x)<br> {<br>
  <div style="margin-left: 40px;">System.out.print("String");<br></div>} <br>void f(StringBuffer x)<br> {<br>
  <div style="margin-left: 40px;">System.out.print("StringBuffer");<br></div>} <br>public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">Test t=new Test(); <br>t.f(test); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5449_23235" name="resp5449_" checked="checked" type="radio" value="23235">        </td>
        <td class="c1 text ">
          <label for="resp5449_23235">
            <span class="anun">a<span class="anumsep">.</span></span> Prints "String"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5449_23236" name="resp5449_" type="radio" value="23236">        </td>
        <td class="c1 text ">
          <label for="resp5449_23236">
            <span class="anun">b<span class="anumsep">.</span></span> Prints "StringBuffer"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5449_23237" name="resp5449_" type="radio" value="23237">        </td>
        <td class="c1 text correct">
          <label for="resp5449_23237">
            <span class="anun">c<span class="anumsep">.</span></span> Prints "Object"            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5449_23238" name="resp5449_" type="radio" value="23238">        </td>
        <td class="c1 text ">
          <label for="resp5449_23238">
            <span class="anun">d<span class="anumsep">.</span></span> Compiler complains about an ambiguous method call            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5449_23239" name="resp5449_" type="radio" value="23239">        </td>
        <td class="c1 text ">
          <label for="resp5449_23239">
            <span class="anun">e<span class="anumsep">.</span></span> Exception thrown at runtime            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5449_23240" name="resp5449_" type="radio" value="23240">        </td>
        <td class="c1 text ">
          <label for="resp5449_23240">
            <span class="anun">f<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice C is the correct answer. <br><br>Here the method f is overloaded with Object, String and StringBuffer arguments. The String literal "hello" is assigned to the variable test which is of Object type. Here even though the actual object passed is String type, the object reference is of Object type. <br><br>The Object type can be assigned only to an Object type reference variable, so the only method which matches in this case is the one which takes Object as the argument. <br><br>So there is no ambiguity here, the output is "Object".      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2057%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5450" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                57      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Given the following class definition, which of the following methods could be legally placed after the comment //Here? Select two choices.<br><br>1. public class Rid <br>2. { <br>3. public void aMethod(int i, String s){} <br>4. //Here <br>5. }</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5450_23241" name="resp5450_23241" checked="checked" type="checkbox" value="23241">        </td>
        <td class="c1 text correct">
          <label for="resp5450_23241">
            <span class="anun">a<span class="anumsep">.</span></span> public void aMethod(String s, int i) {}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5450_23242" name="resp5450_23242" type="checkbox" value="23242">        </td>
        <td class="c1 text ">
          <label for="resp5450_23242">
            <span class="anun">b<span class="anumsep">.</span></span> public int  aMethod(int i, String s) {}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5450_23243" name="resp5450_23243" type="checkbox" value="23243">        </td>
        <td class="c1 text ">
          <label for="resp5450_23243">
            <span class="anun">c<span class="anumsep">.</span></span> public void aMethod(int i, String mystring) {}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5450_23244" name="resp5450_23244" checked="checked" type="checkbox" value="23244">        </td>
        <td class="c1 text correct">
          <label for="resp5450_23244">
            <span class="anun">d<span class="anumsep">.</span></span> public void AMethod(int i, String s) {}            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and D are the correct answers. <br><br>Choice A is correct because it is a valid case of method overloading, where the list of arguments is different. <br><br>Choice B is incorrect because the argument list is not different, it is not enough if the return type alone differs. <br><br>Choice C is incorrect because the same method definition has been repeated, it is not enough to have a different variable name for the argument. <br><br>Choice D is correct because the method name is different, so it is treated as just another method in that class.      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2058%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5451" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                58      </div>
      </div>
  <div class="content">
    <div class="qtext">
  Which of the following is true about the takeOrdersAndServe() method in the below code? <br><br>class Waitor<br>{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void takeOrders(){} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void serveFood(){} <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void takeOrdersAndServe()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;takeOrders(); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serveFood(); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5451_23245" name="resp5451_" type="radio" value="23245">        </td>
        <td class="c1 text ">
          <label for="resp5451_23245">
            <span class="anun">a<span class="anumsep">.</span></span> It exhibits high cohesion            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5451_23246" name="resp5451_" checked="checked" type="radio" value="23246">        </td>
        <td class="c1 text correct">
          <label for="resp5451_23246">
            <span class="anun">b<span class="anumsep">.</span></span> It exhibits low cohesion            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5451_23247" name="resp5451_" type="radio" value="23247">        </td>
        <td class="c1 text ">
          <label for="resp5451_23247">
            <span class="anun">c<span class="anumsep">.</span></span> It exhibits tight coupling            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5451_23248" name="resp5451_" type="radio" value="23248">        </td>
        <td class="c1 text ">
          <label for="resp5451_23248">
            <span class="anun">d<span class="anumsep">.</span></span> It exhibits loose coupling            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>Cohesion refers to the number and diversity of tasks that a single unit is responsible for. If each unit is responsible for one single logical task, we say it has high cohesion. <br><br>Cohesion applies to classes and methods. Here the takeOrdersAndServe() method is not focused on a single task, so it shows low cohesion. A well designed unit will have high cohesion. <br><br>More about coupling, cohesion and other related concepts here. <br><a href="http://satc.gsfc.nasa.gov/support/STC_APR98/apply_oo/apply_oo.html">http://satc.gsfc.nasa.gov/support/STC_APR98/apply_oo/apply_oo.html</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2059%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5452" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                59      </div>
      </div>
  <div class="content">
    <div class="qtext">
  A Vehicle has an owner and a registration number. A Car is a Vehicle that has a steering wheel and a model name. Choose the fields which must be included in the Car class. (The Vehicle class is already defined) Select two choices.<br></div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose at least one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5452_23249" name="resp5452_23249" checked="checked" type="checkbox" value="23249">        </td>
        <td class="c1 text correct">
          <label for="resp5452_23249">
            <span class="anun">a<span class="anumsep">.</span></span> Steering s;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5452_23250" name="resp5452_23250" type="checkbox" value="23250">        </td>
        <td class="c1 text ">
          <label for="resp5452_23250">
            <span class="anun">b<span class="anumsep">.</span></span> Person owner;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5452_23251" name="resp5452_23251" type="checkbox" value="23251">        </td>
        <td class="c1 text ">
          <label for="resp5452_23251">
            <span class="anun">c<span class="anumsep">.</span></span> String registrationNo;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5452_23252" name="resp5452_23252" checked="checked" type="checkbox" value="23252">        </td>
        <td class="c1 text correct">
          <label for="resp5452_23252">
            <span class="anun">d<span class="anumsep">.</span></span> String modelName;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_big.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5452_23253" name="resp5452_23253" type="checkbox" value="23253">        </td>
        <td class="c1 text ">
          <label for="resp5452_23253">
            <span class="anun">e<span class="anumsep">.</span></span> Vehicle c;            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choices A and D are the correct answers.<br><br> Since a Vehicle has an owner and a registration number, the class Vehicle looks like this.<br><br> class Vehicle<br>{ <br>
<div style="margin-left: 40px;">Person owner; <br>String registrationNo; <br></div>} <br><br>As a Car is a Vehicle, Car is a subclass of class Vehicle. So the Car class inherits the fields owner and registration number from the Vehicle class. So the Car class only needs to declare the fields Steering s and String modelName. <br><br>class Car extends Vehicle<br>{ <br>
<div style="margin-left: 40px;">Steering s; <br>String modelName; <br></div>} <br><br>So choices A and D are correct, while the other choices are incorrect. <br><br>Reference: <br><a href="http://cnx.rice.edu/content/m11709/latest/">http://cnx.rice.edu/content/m11709/latest/</a>      </div>
        <div class="grading">
      <div class="correctness  correct">Correct</div><div class="gradingdetails">Marks for this submission: 1/1.</div>    </div>  </div>
</div>
<div style="float:left"><a href="mailto:support@whizlabs.com?subject=Feedback%20to%20author%20for%20Question%2060%20of%20Quiz%20Practice%20Test%20III%20(ID:%201776),%20Course%20ID:%2011">Feedback to Author</a></div><div id="q5453" class="que multichoice clearfix">
  <div class="info">
    <span class="no"><span class="accesshide">Question </span></span>
          <div class="grade">
                60      </div>
      </div>
  <div class="content">
    <div class="qtext">
  What will be the result of compiling and running the following code? <br><br>class SuperTest <br>{<br>
<div style="margin-left: 40px;"> int f() <br>{<br>
  <div style="margin-left: 40px;">return 0; <br></div>}<br></div>} <br>public class Test extends SuperTest <br>{ <br>
<div style="margin-left: 40px;">int i; <br>protected int f() throws Error <br>{ <br>
  <div style="margin-left: 40px;">return i;<br></div> }<br>Test(int i)<br> { <br>
  <div style="margin-left: 40px;">this.i=i;<br></div>}<br> public static void main(String[] args) <br>{ <br>
  <div style="margin-left: 40px;">SuperTest t=new Test(5); <br>System.out.println(t.f()); <br></div>} <br></div>}</div>


<div class="ablock clearfix">
  <div class="prompt">
    Choose one answer.  </div>

  <table class="answer">
          <tbody><tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5453_23254" name="resp5453_" type="radio" value="23254">        </td>
        <td class="c1 text ">
          <label for="resp5453_23254">
            <span class="anun">a<span class="anumsep">.</span></span> Prints 0            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5453_23255" name="resp5453_" type="radio" value="23255">        </td>
        <td class="c1 text correct">
          <label for="resp5453_23255">
            <span class="anun">b<span class="anumsep">.</span></span> Prints 5            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/tick_green_small.gif" alt="Correct" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5453_23256" name="resp5453_" type="radio" value="23256">        </td>
        <td class="c1 text ">
          <label for="resp5453_23256">
            <span class="anun">c<span class="anumsep">.</span></span> Code does not compile, a method with default access cannot be overridden as protected.            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r1">
        <td class="c0 control">
          <input disabled="disabled" id="resp5453_23257" name="resp5453_" checked="checked" type="radio" value="23257">        </td>
        <td class="c1 text ">
          <label for="resp5453_23257">
            <span class="anun">d<span class="anumsep">.</span></span> Code does not compile, a method in the subclass cannot throw exceptions not thrown by the overridden method            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_big.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
          <tr class="r0">
        <td class="c0 control">
          <input disabled="disabled" id="resp5453_23258" name="resp5453_" type="radio" value="23258">        </td>
        <td class="c1 text ">
          <label for="resp5453_23258">
            <span class="anun">e<span class="anumsep">.</span></span> None of the above            <img src="./OCPJP 6 - Exam Simulator  Practice Test III_files/cross_red_small.gif" alt="Incorrect" class="icon">          </label>
        </td>
        <td class="c0 feedback">
                  </td>
      </tr>
      </tbody></table>
    </div>
      <div class="generalfeedback">
        Choice B is the correct answer. <br><br>The code compiles without errors and prints 5. <br><br>Choice C is not valid because protected is more public than default access, so you can override a default method to be protected. <br><br>Error and RuntimeException are unchecked exceptions, so they can be thrown in the overriding subclass method even if the overridden method does not throw them. <br><br>The variable t is of type Test, so at runtime the method invoked is the method f() defined in the subclass. Thus 5 is printed.      </div>
        <div class="grading">
      <div class="correctness  incorrect">Incorrect</div><div class="gradingdetails">Marks for this submission: 0/1.</div>    </div>  </div>
</div>

<div class="controls">
<div class="singlebutton"><form action="http://www.whizlabs.com/examprep/mod/quiz/view.php" method="get"><div><input type="hidden" name="id" value="2204"><input type="submit" value="Finish review"></div></form></div></div>
<!--Start - Display Buttons with their course prices in each moodle pages: Devesh M-->
				
		<!--Start - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
				<!--End - Display Buy Mock Exam Full Version button with price at trial course page only: Devesh M-->
  <div id="leftfooter" style="display: none; "></div><div id="rightfooter" style="display: none; "><p class="footertopma">Thanks Whizlabs for such an excellent product. It really helped me a lot for my achivement. -Nazmul<span class="more"><a href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170708&showall=true#" class="amore"> more</a></span></p>

  </div>

  <div id="rightfooter2" style="display: none; "><p class="copyright">Whizlabs Copyright (C) 2011. All Rights Reserved.</p></div>
<script language="javascript">
	if(document.getElementById("left-column")) {
	
	}
	else {
		document.getElementById('leftfooter').style.display='none';
		document.getElementById('rightfooter').style.display='none';
		document.getElementById('rightfooter2').style.display='none';
	}
</script>
  <div id="footerbottom">
    
 <center>
	<div style="border:0px solid #FFFFFF; font-size:11px; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#000;">
		<br>
		<span><a href="http://www.whizlabs.com/scja/scja.html" title="SCJA Certification" style="text-decoration:none; color:#000;">SCJA Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scjp/scjp.html" title="SCJP Certification" style="text-decoration:none; color:#000;">SCJP Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scwcd/scwcd.html" title="SCWCD Certification" style="text-decoration:none; color:#000;">SCWCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scbcd/scbcd.html" title="SCBCD Certification" style="text-decoration:none; color:#000;">SCBCD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scdjws/scdjws.html" title="SCDJWS Certification" style="text-decoration:none; color:#000;">SCDJWS Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scmad/scmad.html" title="SCMAD Certification" style="text-decoration:none; color:#000;">SCMAD Certification</a></span> |
		<span><a href="http://www.whizlabs.com/scea/scea.html" title="SCEA Certification" style="text-decoration:none; color:#000;">SCEA Certification</a></span>

		<br><br>
		<span><a href="http://www.whizlabs.com/otherpages/legal.html" alt="coming soon" style="text-decoration:none; color:#000;">Legal</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/policies.html" alt="coming soon" style="text-decoration:none; color:#000;">Policies</a></span> |
		<span><a href="http://www.whizlabs.com/otherpages/copyrights-and-trademarks.html" alt="coming soon" style="text-decoration:none; color:#000;"> Copyrights and Trademarks</a></span>
	</div>
	<br>
</center>
</div>
 </div>

<!--End - Display Buttons with their course prices in each moodle pages: Devesh M-->
<!--Footer links for each moodle pages-->


<!--Google Adwords Code Start: Devesh M-->
	<!--quiz/review.php--> 
	<!-- Google Code for Trial Test Reviewed Conversion Page --> 
	<script type="text/javascript">
	<!--
	var google_conversion_id = 1071861065;
	var google_conversion_language = "en";
	var google_conversion_format = "2";
	var google_conversion_color = "ffffff";
	var google_conversion_label = "YhFjCNjMogEQyZqN_wM"; var google_conversion_value = 0; //--> </script> <script type="text/javascript" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/conversion.js">
	</script><iframe name="google_conversion_frame" width="200" height="26" src="./OCPJP 6 - Exam Simulator  Practice Test III_files/saved_resource.htm" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">&lt;img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1071861065/?frame=0&amp;random=1324237922934&amp;cv=7&amp;fst=1324237922934&amp;num=1&amp;fmt=2&amp;value=0&amp;label=YhFjCNjMogEQyZqN_wM&amp;bg=ffffff&amp;hl=en&amp;guid=ON&amp;u_h=1080&amp;u_w=1920&amp;u_ah=1080&amp;u_aw=1920&amp;u_cd=32&amp;u_his=50&amp;u_tz=-120&amp;u_java=true&amp;u_nplug=27&amp;u_nmime=117&amp;ref=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170708%26page%3D59&amp;url=http%3A//www.whizlabs.com/examprep/mod/quiz/review.php%3Fattempt%3D170708%26showall%3Dtrue" /&gt;</iframe>
	<noscript>
	&lt;div style="display:inline;"&gt;
	&lt;img height="1" width="1" style="border-style:none;" alt=""
	src="http://www.googleadservices.com/pagead/conversion/1071861065/?label=YhF
	jCNjMogEQyZqN_wM&amp;amp;guid=ON&amp;amp;script=0"/&gt;
	&lt;/div&gt;
	</noscript>
<!--Google Adwords Code End : Devesh M-->

<!--OnTarget Code Start: Devesh M-->
<script language="JavaScript">
	var s_PageName = "OCPJP 6 - Exam Simulator: Practice Test III";

			</script>

<!--End of OnTarget Code: Devesh M-->

<!-- Start of Google Analytics Code: Devesh M-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="./OCPJP 6 - Exam Simulator  Practice Test III_files/ga.js" type="text/javascript"></script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-320509-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<!--End of Google Analytics Code: Devesh M-->



</body><span id="skype_highlighting_settings" display="none" autoextractnumbers="1"></span><object id="skype_plugin_object" location.href="http://www.whizlabs.com/examprep/mod/quiz/review.php?attempt=170708&amp;showall=true" location.hostname="www.whizlabs.com" style="position: absolute; visibility: hidden; left: -100px; top: -100px; " width="0" height="0" type="application/x-vnd.skype.click2call.chrome.5.6.0"></object></html>